Solution using a proper shell script. The file is processed using the while loop where each line is read in one iteration. The line is assigned to a variable x, and outside the loop, x is printed which will contain the last line of the file. Related Posts Widget. No comments:. Newer Post Older Post Home. To list last 20 lines from the same file, use the following command. I wrote the script in a fairly generic way, so it can be used in various ways.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. EXE batch script to display last 10 lines from a txt file Ask Question. Asked 12 years, 11 months ago. Active 5 years, 11 months ago. Viewed 88k times. Any ideas how to echo or type the last 10 lines of a txt file? The script works great, just need it to pipe more lines to the screen.
Improve this question. Matt Ball Matt Ball. Add a comment. Active Oldest Votes. Improve this answer. Patrick Cuff Patrick Cuff This isn't last 10 lines. It's all lines since line number This works under Windows 7, both 64 and 32 bit consoles. PatrickCuff, oh dammit, sorry, you're right, once again I win the pie. This answer combines the best features of already existing answers, and adds a few twists.
The solution is a simple batch implementation of the tail command. The second argument is the number of lines to print. I am trying to use this for tail -f kind of functionality. AbibullahRahamathulah - No, there is no equivalent to the tail -f option. I have started using the tail. Thanks for your response. For some reason this script counted only lines when the file was actually lines long.
Code: [Select]. Download: Choice. Sorry, I am not getting it. Dias de verano Guest. Needed fixing, I think. Try this. Works now.
Thanks for your help, it is much appreciated. Pages: [ 1 ] Go Up.
0コメント