Apr 13, 2001 #1 Mnaim Technical User Joined Apr 13, 2001 Messages 1 Location NO Im new awk user. Any body can help me to print last 10 lines from file using awk
Apr 14, 2001 #2 flogrr Programmer Joined May 4, 2000 Messages 142 Location US Hi Mnaim- You can use this unix command: tail lnfile # prints last 10 lines by default tail -30 lnfile # prints last 30 lines You can also use this short awk script: awk ' {line[NR] = $0} END { print "Here are the last 10 lines of file: "FILENAME"\n\n" i = NR - 9 while ( i <= NR ) { print line i++ } }' lnfile | more Hope this helps you! flogrr flogr@yahoo.com Upvote 0 Downvote
Hi Mnaim- You can use this unix command: tail lnfile # prints last 10 lines by default tail -30 lnfile # prints last 30 lines You can also use this short awk script: awk ' {line[NR] = $0} END { print "Here are the last 10 lines of file: "FILENAME"\n\n" i = NR - 9 while ( i <= NR ) { print line i++ } }' lnfile | more Hope this helps you! flogrr flogr@yahoo.com