hey can anyone tell me how can i combine these two commands so that it is executed only once, but gives me both the results.
IDLE=`sar 30 6 | grep Average | awk '{print $1 $5}' `
sar 30 120 | awk '{print $1" "$5}' >> mailx -m -s "$MSG" xyz@abc.com.
hey can anyone tell me how can i combine these two commands so that it is executed only once, but gives me both the results.
IDLE=`sar 30 6 | grep Average | awk '{print $1 $5}' `
sar 30 120 | awk '{print $1" "$5}' >> mailx -m -s "$MSG" xyz@abc.com.
elaborate...
Well the first command will grep average out of the sar into the vartiable IDLE and the second command will just mail the output of sar. I need a command that does both of this once. The commands have to be run separately or one after the other. Which means more time consumption. I need to accomplish both the tasks in one line.
i think you can put the output of
sar | awk in a file and then grep in this file for Avg and send the file as mail.
Here, sar and awk are the only command which are time consuming.
Yeah that can be done. I can also use a tee. but i am on the lookout of a solution without usage of a file. Cant have a file. not even a temp one. so you think there is any way out?
In the second command the ">>" will create a file called "mailx" rather than send a mail.
Maybe you mean:
sar 30 120 | awk '{print $1" "$5}' | mailx -m -s "$MSG" xyz@abc.com
Also, because it executes sar 120 times at 30 second intervals it will take an hour.
To run the two commands sequences consecutively on the same line, separate them with a semi-colon .