如题,
~>grep -o . file | sort |uniq -c
grep . file
//从名为file的文件中搜寻匹配 . 号的的部分,这样写相当于执行cat file在终端输出的内容一样,加了 -o 就相当于每个字符占用一行
-o, --only-matching
Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
渣翻译:打印非空的匹配部分,每个(匹配)单独输出成一行。
~>grep -o . file | sort
|是shell里管道的概念,不这样做的话就得先把grep命令执行后的结果重定向到文件中,再从文件中将文件里的内容导向sort指令,太过于麻烦。给个示例:
~>date > file1
~>wc < file1
wc是统计行数、字数、字节数的函数
之后就很明白了,uniq就是去除重复,-c就是统计个数的意思了。
最后记录两个CLI下的命令:
ctrl+shift+c 终止当前执行的命令
ctrl+l 清除标签里的内容