$ ps auxw |awk /$variable/ |awk !/awk/ |wc -l
For example. If I were to check the status of cron I would type something as shown below
$ ps auxw |awk /cron/ |awk !/awk/
root 4980924 0.0 0.0 1276 1300 - A Jan 07 3:12 /usr/sbin/cron
我正在写一个脚本,在这个脚本中,我需要在awk代码块中传递变量的值,就像下面这样
我曾使用ps -ef $variable awk