wc命令

[root@localhost demo]# cat luffy.txt
10.0.0.1
10.0.0.1
10.0.0.51
10.0.0.51
10.0.0.1
10.0.0.1
10.0.0.51
10.0.0.31
10.0.0.51
10.0.0.12
10.0.0.5
10.0.0.5
10.0.0.5
[root@localhost demo]# cat -n luffy.txt
     1  10.0.0.1
     2  10.0.0.1
     3  10.0.0.51
     4  10.0.0.51
     5  10.0.0.1
     6  10.0.0.1
     7  10.0.0.51
     8  10.0.0.31
     9  10.0.0.51
    10  10.0.0.12
    11  10.0.0.5
    12  10.0.0.5
    13  10.0.0.5
[root@localhost demo]# wc -l luffy.txt #统计文件的行数
13 luffy.txt
[root@localhost demo]# echo "wo ai ni zhong guo" | wc -w #统计单词数量
5
[root@localhost demo]# echo "wo ai ni zhong guo" | wc -m #统计字符数量,但是注意字符串结尾有个$符号
19
[root@localhost demo]# echo "wo ai ni zhong guo" | cat -E
wo ai ni zhong guo$

[root@localhost demo]# cat alex.txt
my name is alex.

he love linux.

he like eat apple.

[root@localhost demo]# cat alex.txt | wc -L #输出最长行的字符数
19

 
 

 

posted @ 2025-01-07 08:57  鲁班大师智商二百五  阅读(5)  评论(0)    收藏  举报