我想用op / s提取值
pgmap 512 pgs:512次有效+清除; 1.39TiB数据,使用4.08TiB,1.15TiB / 5.24TiB可用; 4.43MiB / s wr,46op / s
pginfo="pgmap 512 pgs: 512 active+clean; 1.39TiB data, 4.08TiB used, 1.15TiB / 5.24TiB avail; 4.43MiB/s wr, 46op/s"
echo $pginfo | sed -n '/pgmap/s/.* \([0-9]*\) op\/s.*/\1/p'
但是它不返回任何东西。任何帮助指针将不胜感激。
答案 0 :(得分:0)
您的正则表达式在数字后寻找空格,但没有空格。
此外,您还应引用已回显的变量以防止其被破坏。
echo "$pginfo" | sed -n '/pgmap/s/.* \([0-9][0-9]*\)op\/s.*/\1/p'