Having completed the coding of my BTP, I had to test the program. I wrote down a simple C program to do this and generate the outputs in log files in a specified folder. However, I messed it up big time. The actions included creating temporary files, catenating them and then moving them. I did it horribly wrong and ended up with lots of garbage in each log file. Only the last 50 lines of each file were the results, rest garbage.
I needed a way to retain the last 50 lines of each file and discard the rest. This is when I stumbled across the tail command. It does exactly this ! All you have to do call tail -50 <filename> for each of the files. Sweet !
A simple recursive loop, calling the tail command for each file, and yay I am done with my work. Now it is the time to analyse the results.
Popularity: 4% [?]
Related posts:
0 Responses to “Printing The Last 50 Lines Of A File”