WC
wc:word count 统计character,newline,
-l:统计行数
-c:统计字节数
-m:字符数
-w:字数
-L:文件最长行的字符数
无参数:行数,字数,字符数
ls | wc -l//To count all files and folders present in directory
wc -n | cut c1//Display number of word count only of a file
cut
取文件每行的某个部分
cutting out the sections from each line of files
-b:取某些字节 可有以下范围
n | n- | -n | n-m |
---|---|---|---|
某个字节 | 从n到行结束 | 第一个到n | 第n到m个 |
-c:取某些列
-f:取某些域,由delimiter区分,
-d:设置delimiter
–complement:互补
–output-delimiter:设置输出的delimiter
cut -b 1- state.txt
cut -c -5 state.txt
cut -f 1 state.txt
cut -d " " -f 1-4 state.txt
cut --complement -c 5 state.txt
cut -d " " -f 1,2 state.txt --output-delimiter='%'
cat state.txt | cut -d ' ' -f 1 | sort -r
cat state.txt | head -n 3 | cut -d ' ' -f 1 > list.txt
head
读文件的顶部,默认是10行
-n :多少行
-c:多少个字节
-q:不输出文件名字,用于多个文件
head -n 5 state.txt
head -c 6 state.txt
head -q state.txt capital.txt