awk ?
I have a .out file that has this information:
-rw-r--r-- 1 root system 1763444 Sep 30 18:11 log.td-ict-111 I just want a simple script to list only the last row of informatin (the log. names) How can I do this with awk? |
Quote:
Awk, by default, splits things on white-space. So if you put your string into it, you want to print out field 9, based on your example. Code:
awk '{print $9}' |
here's a nifty link
http://forums13.itrc.hp.com/service/...readId=1154641 the awk one-liner awk 'END {print}' file sed '$!d' file (- bonus) |
NF means number of fields in awk. You can use $NF to refer to the last field.
Code:
awk '{print $NF}' myfile.out |
Why not use tail?
Just curious: Why use awk when you can use "tail -1 <file>"?
|
Quote:
|
pixellany was correct I was needing the last column of data from the .out file. The command that cpplinux suggested (awk '{print $NF}' myfile.out) worked perfectly in my applicaion.
Thanks to all for the help :) |
All times are GMT -5. The time now is 04:51 PM. |