Last active
August 29, 2015 14:19
-
-
Save disciplezero/d869319693940e35950b to your computer and use it in GitHub Desktop.
getMaxKey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=$1 | |
USER=$2 | |
PASS=$3 | |
TABLE=$4 | |
KEY=$5 | |
# head/tail to get the second line. The first column is the field, so we delete everything afterwards. | |
mysql -h $HOST -u $USER --password=$PASS sw -e 'select '"$KEY"' from '"$TABLE"' order by '"$KEY"' desc limit 1'| head -2 |tail -1|sed "s/\t.*//g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment