Linux共通コマンド3-テキスト処理クラスコマンド
1245 ワード
本編ではwc,cut,sort,uniqに関する命令を含む.
wc:
print newline, word, and byte counts for each file
cut:
JavaのStringTokenIzerに相当し、指定した区切り文字列の
sort: sort lines of text files
uniq
wc:
print newline, word, and byte counts for each file
-l:
-w: word
-c: byte
[root@localhost ~]# wc /etc/passwd
37 53 1682 /etc/passwd
[root@localhost ~]# cat /etc/passwd | wc
37 53 1682
[root@localhost ~]# ls -d /etc/[pP]* | wc -l// /etc p
28
cut:
JavaのStringTokenIzerに相当し、指定した区切り文字列の
-d:
-f:
m: m
m,n: m n
m-n: m n
# cut -d: -f1,7 /etc/passwd// shell
sort: sort lines of text files
sort [option] FILE...
-f:
-t:
-k:
-n:
-u:
# cut -d: f7 /etc/passwd | sort | uniq// shell
[root@localhost ~]# cut -d: -f1,4 /etc/passwd | sort -t: -k2// /etc/passwd 1 4 , 4 (1,10,101,2,21...)
[root@localhost ~]# cut -d: -f1,4 /etc/passwd | sort -t: -k2 -n// /etc/passwd 1 4 , 4 (1,2,10,21,101...)
uniq
-d:
-u:
-c:
# head -n 7 /etc/inittab | tail -n 1// etc/inittab 7