I just found out I can use less with multiple files. less status line tells me
(END) - Next: file2.txt
But how do I navigate previous/next from less?
I just found out I can use less with multiple files. less status line tells me
(END) - Next: file2.txt
But how do I navigate previous/next from less?
We read in the manpage:
:n Examine the next file (from the list of files given in the com‐
mand line). If a number N is specified, the N-th next file is
examined.
:p Examine the previous file in the command line list. If a number
N is specified, the N-th previous file is examined.
Found out from :h (help window) that I can use :p (for previous) and :n (for next)
Note: you actually have to type the : for these commands (even though there is a colon visible already).
:n jump to next file
:p jump to previous file
:x jump to first file
3:n jump 3 files ahead
3:p jump 3 files back
3:x jump to 3rd file
:f print current file name/info (helpful if you forget where you are)
Not strictly an answer for that question but maybe someone can find this useful nevertheless.
If the number of files is reasonably small, one could use vim for that:
vim -O files*
In this way all the files are displayed at once by splitting the screen automatically.
(Use -o to split horizontally.)
Some basic vim survival commands for this use case:
vim (!!!).I find the :n binding cumbersome, so I often use the more command instead. (The name less is a wordplay on more, after all.)
more just uses the space bar to advance to the next file, and prints a header before each one. Example:
$ more *.txt
::::::::::::::
a.txt
::::::::::::::
Example file A
::::::::::::::
b.txt
::::::::::::::
Example file B
--More--(Next file: c.txt)
For one line or really short files, I usually use grep . *.txt, because it will prefix each file with the file name:
$ grep . *.txt
a.txt:Example file A
b.txt:Example file B
c.txt:Example file C