bourne
1
I have a text:
dsj khfksjdh <time> EST 2006
ab cgnr jkkjt <time> EST 2006
gfhdgjghg <time> EST 2006
fkdjh kjhsekjrh kdjhfkh jhdfkhfdkjh kjdf <time> EST 2006
In the above file i need to extract time from every line... which is always the third from the last... Pls help!
Cheers,
Bouren
If you want only the third from the last field, this should work:
awk '{print $(NF-2)}' file
If you want the last three fields, try:
awk '{print $(NF-2), $(NF-1), $NF}' file
Krrishv
3
cat <filename>|awk '{print $(NF-2)}'
anbu23
5
sed "s/.*\(<time>.*\)$/\1/" file