zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux shell 脚本攻略学习笔记八

Linux笔记学习shell 脚本 攻略
2023-09-14 09:13:15 时间

Linux shell 脚本攻略学习笔记八之wc命令

1.wc 命令

wc - print newline, word, and byte counts for each file [打印每个文件的换行,单词,字节数。]

  -l, --lines
    print the newline counts
  -w, --words
    print the word counts

2.示例如下

[root@server4 shells]# echo -e "hello spark \nwo men dou shi hao hai zi \n"
hello spark 
wo men dou shi hao hai zi 

[root@server4 shells]# echo -e "hello spark \nwo men dou shi hao hai zi \n" | wc -w
9
[root@server4 shells]# man wc
[root@server4 shells]# echo -e "hello spark \nwo men dou shi hao hai zi \n" | wc -l
3