I've found one way so far: less +G filename, but it's scroll up only with up key line by line. What's more powerful less usages which provide scrolling by page, pattern search backward and so on?
I'm sure someone else has a better answer, but
With "less" after you've opened the file:
G goes to the bottom of the file ^b goes up one page ? searches backwards.
As you said, you can open the file with +G and then use ? and ^b to scroll up. There are likely clever awk things you can do to achieve the same thing in a script.
For variety, if you actually want/need to read a file backwards (last line first):
tac filename | less
w goes up by page.
? does reverse search.
h brings up online help.
tail -r | less
I don't know why anyone didn't think of this one. Tail grabs the end of a file really easy. Is -r not a common option?
While using more for example
journalctl -xe using space bar takes you 1 page down. That worked for me. Hope this helps.
less +F /path/to/your/file
that's less but starting from the bottom. Use the up arrow key to go backwards line by line or ctl+b to go page by page.
I'm surprised nobody brought this up before, but:
?pattern searches for pattern backwards.
N finds the previous match of the pattern (that is, searching backwards).
/pattern searches for pattern forward and
n finds the next match of the pattern. That's the way the search is commonly used.
Another alternative, after you have started less on a file:
alt + "end-key"
With "end-key" I mean the key that is usually located below the "home-key" on a keyboard.
If you're looking for something specific, this might do it:
cat yourfile.txt | grep "something specific" | less
I use it for searching log files. It's still in the 'wrong' order though, but much shorter.
After reading Dennis Williamson's answer, that's my new method =)
Perhaps some people did not understood what dr01 meant. I try to put it in other words.
- Open the file in less
- Forward search: Enter the key /
- Backward search: Enter the key ?
- For both of the preceding: Enter your search term now
- Press enter
- Press n to search for the next finding
- Press N to search for the previous finding