can u help me out to print last two words of each sentence of a file.
for example.
contents of input file:
i love songs
my favourite songs
sent
songs all kind
good buddy
Ouput file should contain:
love songs
favourite songs
sent
all kind
good buddy
otheus
2
This sounds like a homework question. Please read the site FAQ.
awk '{ if (NF > 1) print $(NF-1),$NF ; else print $NF; }'
Hi.. Check the code using awk
cat <File name>> | awk '{ as=split($0,TagArr," "); st = sprintf("%s%s", TagArr[as-1],TagArr[as]); print st; }'
Looks like your posts are homework questions.
thanks for u reply.
Since i am new to shell script can u explain in detials
thanks for ur reply
can u explain in detail
AS i have tried it out but getting lot of bugs