How do I 'cat' a text file but start from the bottom instead of top
Try the tac
command, which reverses the input, line by line.
Alternatively, less
is more
. Start at the end of the file using +G
:
less +G some-file
You might have to get used to pressing b (which jumps back a screen) instead of Space.
Related videos on Youtube
Parto
Far better it is to dare mighty things, to win glorious triumphs, even though checkered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the gray twilight that knows neither victory nor defeat. ― Theodore Roosevelt
Updated on September 18, 2022Comments
-
Parto over 1 year
I have a very big text log file of about 37MB.
Usingcat file | more
I can view the file contents one page at a time.The problem is that this always starts from the top - the old entries.
How can I make it start from the bottom where the newer entries are then move up page by page? -
Parto about 9 years
tac
starts at the bottom but I can't get a way to go up a screen.less some-file +G
doesn't seem to work. -
muru about 9 years@Parto go up a screen in what? As for +G, open the file in less, then press Shift-G. Does it go to the end of the file?
-
muru about 9 years@Parto apparently less doesn't follow the Vim convention of allowing commands after filenames even though it borrows key strokes from it. Try
less +G some-file
. -
Ville over 7 years
less +G
seems more natural when viewing command line history, for example. Something like this:alias h='history -999999 | less +G'