I am writing a script where I need to pass the variable value inside the awk code block like this
$ 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
I had used ps -ef |grep cron |grep -c -v cron however when I executed the script, it would report the line count of two when I had only one line output. Could someone help?