cat|grep|awk
i have files like jul07, jul08 which contains a data as follow
Wed Jul 9 16:45:01 IST 2008 Mem Used 744 hddMounted Used Avail /apps 2.2G 31G now i need to have the time (16:45) and Mem used (744) tobe extracted and display in timely order can anyone help me? cat Jul090000 |grep 'Mem Used' |awk '{print $3}' gives me 744 how to add 16;45 along with this? |
Use the same technique to extract "16:45" and put it in a variable. Then use that variable in combination with the other command.
really good AWK tutorial here: http://www.grymoire.com/Unix/Awk.html |
but i have multiple files like this,
|
To do the same thing on multiple files, you would simply put your script in a structure such as this:
Suppose your script is "wordsmasher", and you have all your files in one directory: for file in ls; do wordsmasher $file <<other commands>> done |
Thanks for your help
|
You could grab the time like this:
head -1 <yourfilename>|awk '{print $4}' |
Code:
$ cat data1 data2 |
All times are GMT -5. The time now is 06:19 AM. |