Basic commands for text (CAT, TAC, head, tail, more, less, rev)
Viewing the contents of a file cat
cat-n/etc/passwd can list serial number display file
[Email protected] ~]# cat-n/etc/passwd 1root:x:0:0:root:/root:/bin/bash 2bin:x:1:1:bin:/bin:/sbin/nologin 3 Daemon:x:2:2:daemon:/sbin:/sbin/nologin 4adm:x:3:4:adm:/var/adm:/sbin/nologin 5lp:x:4:7:lp:/var/spool/lpd:/sbin/ Nologin 6sync:x:5:0:sync:/sbin:/bin/sync
cat-a add $ suffix at the end of each line
[Email protected] ~]# cat-a/etc/resolv.conf; Generated By/sbin/dhclient-script$nameserver 192.168.20.2$nameserver 8.8.8.8$$
View the contents of a file in a paginated display
More Space Key page return to the top shift Q key to exit
viewing the contents of a file less
The Space bar page, enter the key down, you can press the arrow key up Move Down, pageup PageDown can page up and down, Q key exit
Ctrl+f PAGE Down
Ctrl+b PAGE Up
J Flip Down
K Upward Turn
G jump to the last line
G Jump to the first line
/Search Down
? Go up search
Show only the first 10 lines of the file head
Head-n 20/etc/passwd Displays the first 20 lines of content
HEAD-N20/ETC/PASSWD display the first 20 lines, no spaces behind n
HEAD-20/ETC/PASSWD the middle parameter n can be omitted, the middle cannot have the space
[Email protected] ~]# head-5/etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x : 2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
Only 10 lines of content are displayed after the file tail
Tail-n 2/etc/passwd shows the last 2 rows, and the same middle parameter n can be omitted
Tail-f/var/log/messages #-F Dynamic View System log
[Email protected] ~]# tail-5/etc/passwdsaslauth:x:499:76: "SASLAUTHD user":/var/empty/saslauth:/sbin/ Nologinpostfix:x:89:89::/var/spool/postfix:/sbin/nologinsshd:x:74:74:privilege-separated SSH:/var/empty/sshd:/ Sbin/nologinuser1:x:500:501::/home/user1:/bin/bashuser2:x:501:502::/home/user2:/bin/bash
Display the contents of the file upside down Rev
[[email protected] ~]# echo ' AABB ' >huang[[email protected] ~]# cat Huangaabb[[email protected] ~]# rev Huangbbaa
Display the contents of a file upside-down TAC
[email protected] ~]# cat Huangaabbcc[[email protected] ~]# TAC Huangccbbaa
This article is from the "Model Student's Learning blog" blog, please be sure to keep this source http://8802265.blog.51cto.com/8792265/1621909
Basic commands for Linux files