我正在编写一个脚本,其中需要像这样在awk代码块内传递变量值
$ 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
我使用了ps -ef | grep cron | grep -c -v cron,但是当我执行脚本时,当我只有一行输出时,它将报告两行的行数。 有人可以帮忙吗?