The “less” command in Linux is used to view the contents of a text file one page at a time. It is similar to the “more” command, but it has several additional features, such as the ability to scroll backwards and forwards through the file, search for text, and navigate by line or percentage. Here are a few examples of how the command can be used:
- To view a text file one page at a time, use the following command:
$ less file.txt
Where “file.txt” is the name of the file you want to view.
- To search for a specific word or phrase within a file:
$ less file.txt
/search-string
Where “search-string” is the word or phrase you’re searching for. To move to the next match press ‘n’
- To go to the end of the file
$ less file.txt
G
or
$ less file.txt
END
- To go to the beginning of the file
$ less file.txt
1G
- To view a file and show line number
$ less -N file.txt
- To filter the contents of a file, using a regular expression,
$ less file.txt
!grep -i "string"
This will filter the content and show the lines that contain the “string”
The “less” command is extremely useful when working with large text files, as it allows you to view and navigate through them in a more manageable way. The “less” command also accepts input from pipes and can be used in combination with other command-line tools to filter and manipulate the data in powerful ways.
Other Linux Commands
- admin Command
- alias Command
- apt Command
- ar Command
- asa Command
- at Command
- awk Command
- basename Command
- bash Command
- batch Command
- bc Command
- bg Command
- break Command
- c99 Command
- cal Command
- cat Command
- cd Command
- cflow Command
- chgrp Command
- chmod Command
- chown Command
- chroot Command
- cksum Command
- clear Command
- cmp Command
- comm Command
- command Command
- compress Command
- continue Command
- cp Command
- crontab Command
- csplit Command
- ctags Command
- cut Command
- cxref Command
- datamash Command
- date Command
- dc Command
- dd Command
- delta Command
- df Command
- diff Command
- dir Command
- dirname Command
- dot Command
- du Command
- echo Command
- ed Command
- env Command
- eval Command
- ex Command
- exec Command
- exit Command
- expand Command
- export Command
- expr Command
- false Command
- fc Command
- fg Command
- file Command
- find Command
- flex Command
- fold Command
- fort77 Command
- fortune Command
- ftp Command
- fuser Command
- gawk Command
- gencat Command
- get Command
- getconf Command
- getopts Command
- grep Command
- groupadd Command
- groupdel Command
- groups Command
- hash Command
- head Command
- history Command
- hostname Command
- htop Command
- iconv Command
- id Command
- iostat Command
- ipcrm Command
- ipcs Command
- jobs Command
- join Command
- kill Command
- last Command
- less Command
- lex Command
- link Command
- ln Command
- locale Command
- localedef Command
- locate Command
- logger Command
- login Command
- logname Command
- logout Command
- lp Command
- ls Command
- m4 Command
- mailx Command
- make Command
- man Command
- mesg Command
- mkdir Command
- mkfifo Command
- mktemp Command
- more Command
- mount Command
- mtail Command
- mv Command
- nano Command
- netstat Command
- newgrp Command
- nice Command
- nl Command
- nm Command
- nohup Command
- od Command
- parallel Command
- passwd Command
- paste Command
- patch Command
- pathchk Command
- pax Command
- pgrep Command
- ping Command
- pkill Command
- pr Command
- print Command
- printf Command
- prs Command
- ps Command
- pstree Command
- pwd Command
- qalter Command
- qdel Command
- qhold Command
- qmove Command
- qmsg Command
- qrerun Command
- qrls Command
- qselect Command
- qsig Command
- qstat Command
- qsub Command
- read Command
- readlink Command
- readonly Command
- renice Command
- return Command
- rm Command
- rmdel Command
- rmdir Command
- rsync Command
- sact Command
- sar Command
- sccs Command
- sed Command
- seq Command
- set Command
- sh Command
- shift Command
- shopt Command
- sleep Command
- sort Command
- split Command
- ss Command
- stress Command
- strings Command
- strip Command
- stty Command
- suspend Command
- tabs Command
- tail Command
- talk Command
- tee Command
- test Command
- time Command
- times Command
- top Command
- touch Command
- tput Command
- tr Command
- traceroute Command
- trap Command
- true Command
- ts Command
- tsort Command
- tty Command
- type Command
- ulimit Command
- umask Command
- umount Command
- unalias Command
- uname Command
- uncompress Command
- unexpand Command
- unget Command
- uniq Command
- unlink Command
- unset Command
- unzip Command
- uptime Command
- useradd Command
- userdel Command
- uucp Command
- uudecode Command
- uuencode Command
- uustat Command
- uux Command
- val Command
- vi Command
- w Command
- wait Command
- wc Command
- what Command
- whereis Command
- which Command
- who Command
- write Command
- xargs Command
- yacc Command
- zcat Command
- zip Command
- Linux Commands and Examples
0 Comments