I've found one way so far:
less +G filename, but it scrolls up line-by-line only with ↑.
What's a more powerful
less usage which provides scrolling by page, backward pattern search, and so on?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
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.
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.
Open the file straight to the end (
less +G path/to/filename.
It will automatically start "calculating line numbers." If the file is huge (ex: many GiB), press Ctrl + C to stop that, since it could take forever.
Now, here are some keys to navigate:
/to search forwards, pressing n to go to the next match down, and Shift + n to go to the next match up.
?to search backwards, pressing n to go to the next match up, and Shift + n to go to the next match down.
less +G filenameto open the file straight to the end.
Perhaps some people did not understood what dr01 meant. I try to put it in other words.