A bit of sed and awk magic
The task is to find the total cpu utilization of httpd processes.
Instead of doing all kinds of acrobatics with grep,bc and bash loops , one can simply use awk.
$ps aux | awk '/httpd/{s+=$3}END{print s}'
One a side note , gnu sed can change a file in-place .This is done by using the "i" option.
$sed -i 's/fun/bun/' test.txt
Instead of doing all kinds of acrobatics with grep,bc and bash loops , one can simply use awk.
$ps aux | awk '/httpd/{s+=$3}END{print s}'
One a side note , gnu sed can change a file in-place .This is done by using the "i" option.
$sed -i 's/fun/bun/' test.txt
0 Comments:
Post a Comment
<< Home