Shell
提取字元串的子字元串
如何
3ccc2392-45ed-11e7-bc98-4061862b8d34:1-35942477
從以下字元串中提取?mysql-bin.000025 217141189 3ccc2392-45ed-11e7-bc98-4061862b8d34:1-35942477,
它是通過
line=$(head -n 1 ./xtrabackup_binlog_info)
像這樣
awk
:$ line="$(head -n 1 ./xtrabackup_binlog_info)" $ echo "$line" | awk -F'[[:blank:]]+|,' '{ print $3 }' 3ccc2392-45ed-11e7-bc98-4061862b8d34:1-35942477
使用
awk
:awk 'BEGIN{ FS="[,[:blank:]]+"; }; { print $(NF-1); exit; }'