问题
I need to capture a value of "seconds_behind_master" column.
SHOW SLAVE STATUS;
How to achieve it ?
回答1:
In a shell script or on the command line on Linux you could:
SECONDS_BEHIND=$(mysql -usome_user -psome_pass -e "show slave status" -E | grep "Seconds_Behind_Master:" | cut -d: -f2)
回答2:
SECONDS=$(mysql -uuser -ppass -Pport -e"show slave status\G" grep Seconds_Behind_Master | awk '{print $2}')
来源:https://stackoverflow.com/questions/39850240/how-to-capture-a-column-values-form-show-slave-status