matthew@seymour:~$ less -MN 1.txt 2.txt 3.txt
This loads all three files into less, starting at 1.txt. When viewing several
files, less usually tells you which file you are in and numbers the files:
1.txt (file 1 of 3) should be at the bottom of the screen. However,
certain things make that go away, so you should use -M anyway.
You can navigate between files by typing a colon and then pressing n to go to
the next file or pressing p to go to the previous file; these are referred to from
now on as :n and :p. You can open another file for viewing by typing :e
and providing a filename. This can be any file you have permission to read,
including files outside the local directory. Use Tab to complete filenames.
Files you open in this way are inserted one place after your current position,
so if you are viewing file 1 of 4 and open a new file, the new file is numbered
2 of 5 and is opened for viewing right away. To close a file and remove it
from the list, use :d.
Viewing multiple files simultaneously has implications for searching. By
default, less searches within only one file, but it is easy to search within all
files. When you type / or ? to search, follow it with a *. You should see
EOF-ignore followed by a search prompt. You can now type a search, and
it runs through the current file; if nothing is found, the search looks in
subsequent files until it finds a match. You can repeat searches by pressing
Esc and then either n or N. The lowercase option repeats the search forward
across files, and the uppercase option repeats it backward.
The last thing you need to know is that you can get to a shell from less and
execute commands. The simplest way to do this is just to type ! and press
Enter. This launches a shell and leaves you free to type all the commands you
want, as per normal. Type exit to return to less. You can also type specific
commands by entering them after the exclamation point (!), using the special
character % for the current filename. For example, du -h % prints the size of
the current file. Finally, you can use !! to repeat the previous command.
Creating Links Between Files with ln
Linux allows you to create links between files that look and work like normal
files for the most part. Moreover, it allows you to make two types of links,
known as hard links and symbolic links (symlinks). The difference between
the two is crucial, although it might not be obvious at first.
Each filename on your system points to what is known as an inode, which is