Linux File Viewing and content processing: less command syntax and instance explanation, less instance explanation
1. Command description:
The less command is used to display the file content by page, but the usage of less is more flexible than that of more. The more command cannot be used to look forward, but can only look back. The less command can not only read forward or backward files, but also provide more search functions, not only to search down, but also to search up. Common Shortcut Keys include:
Press the up arrow key: scroll forward a row. Press the direction key to scroll back a row. Press PgUp to scroll up the page. Press PgDn to scroll down the page. Press the q key to exit the less command. Press/to search for the "string" function. Press? Key: the "string" function is searched up.
2. Syntax:
Less [Option]... file list...
3. instance:
After less-N/var/log/message is executed, the following content is displayed (where the-N option is used to display the row number of each line ):
1 Feb 19 16:20:01 centos systemd: Started Session 6 of user root. 2 Feb 19 16:20:01 centos systemd: Starting Session 6 of user root. 3 Feb 19 16:22:44 centos kernel: hrtimer: interrupt took 1315710 ns 4 Feb 19 16:25:52 centos dhclient[828]: DHCPREQUEST on ens33 to 192.168.229 4 .254 port 67 (xid=0x7adc6a1b) 5 Feb 19 16:25:52 centos dhclient[828]: DHCPACK from 192.168.229.254 (xid=0 5 x7adc6a1b) 6 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6903] dhc 6 p4 (ens33): address 192.168.229.129 7 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6906] dhc 7 p4 (ens33): plen 24 (255.255.255.0) 8 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6906] dhc 8 p4 (ens33): gateway 192.168.229.2 9 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6906] dhc 9 p4 (ens33): server identifier 192.168.229.254 10 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6906] dhc 10 p4 (ens33): lease time 1800 11 Feb 19 16:25:52 centos NetworkManager[726]:
[1519028752.6907] dhc:
As shown above, the first column is the row number of each line. When verifying the related shortcut key operation, you can use the row number as a reference.