05 September 2021
Bash provides several commands to show a file, like cat, but frequently I also use less
command.
Less is a command wrote by Mark Nudelman initially during 1983–85, in the need of a version of more able to do backward scrolling of the displayed text. (From wikipedia)
Note: all example below could be execute in a container:
docker run -it ubuntu /bin/bash
# apt update && apt install -y less
$ less -N /etc/gai.conf
Then press 34g
$ less -N /etc/gai.conf
Then press G
to go to the end of a file
Then press g
to go to the begin of a file
$ less -N /etc/gai.conf
Then press /
followed by a string (regex) to search, example: /label [a-z0-9]
To navigate through use n
next match and N
previous match.
less --help