Linux document processing command

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_41596915/article/details/100060477

First, the document replacing lowercase letters to uppercase

[ziyang0421@bogon Documents]$ cat test1.txt | tr a-z A-Z
TEST1.TXT
LINE2
LINE3
LINE4
LINE5
LINE6
LINE7

Second, in order: a delimiter, using the sort command to / etc / passwd file sorted in the fifth paragraph (only five columns)

[ziyang0421@bogon Documents]$ cat /etc/passwd | sort -t ':' -k5 |head -5 
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
bin:x:1:1:bin:/bin:/sbin/nologin

Third, in order: a delimiter, taken using the cut command / etc / passwd the first paragraph of the document (only the first five columns)

[ziyang0421@bogon Documents]$ cat /etc/passwd | cut -d ':' -f 1 | head -5
root
bin
daemon
adm
lp

Guess you like

Origin blog.csdn.net/qq_41596915/article/details/100060477