First, awk extracts the string method between the double quotes:
such as text: speed= "1000"
Echo ' speed= ' 1000 ' | Awk-f ' "' {print $} '
You can also use sed:
Echo ' speed= ' 1000 ' | Sed-e ' s/. "([0-9]+)". /\1/'
Second, the shell uses the regular extraction of the data inside the parentheses:
As an example:
Su-mqm-c ' echo ' dis qmstatus conns "| RUNMQSC MQXXX999 ' | grep qmname
Qmname (MQXXX999) STATUS (RUNNING)
We're going to just extract MQXXX999 how to do it?
Su-mqm-c ' echo ' dis qmstatus conns "| RUNMQSC MQXXX999 ' | grep Qmname | Sed "s/. Qmname ([0-9a-za-z]). */\1/g "
MQXXX999
Methods for extracting the trailing or preceding values of commas, colons, and other symbols:
As an example:
/bin/echo "Db.serverstatus ()" |/data/software/zabbix tool/mongodb-linux-x86_64-ubuntu1604-3.6.7/bin/mongo 192.168.1.100:29017/chenchen-ulichao-pchenchen | grep ' "Getmore" '
The output is:
We want to extract the value 2 How to extract it?
Add a Awk-f "[,]" ' {print $} ' to the rear. If you want to split awk-f "[:]" ' {print $} ' with a colon. Okay, that's it. This follow-up will be updated.
Drainage pits: Regular expressions used in operation and maintenance