3

linux下部分文件常用命令

 3 years ago
source link: https://www.wencst.com/archives/341
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

linux下部分文件常用命令

作者: wencst 分类: linux,Uncategorized 发布时间: 2016-10-10 16:14 阅读: 2,162 次

Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数、字数、行数,并将统计结果显示输出。

-c 统计字节数。

-l 统计行数。

-m 统计字符数。这个标志不能与 -c 标志一起使用。

-w 统计字数。一个字被定义为由空白、跳格或换行字符分隔的字符串。

-L 打印最长行的长度。

-help 显示帮助信息

–version 显示版本信息

[root@localhost test]# wc test.txt

 7  8 70 test.txt

[root@localhost test]# wc -l test.txt 

7 test.txt

[root@localhost test]# wc -c test.txt 

70 test.txt

[root@localhost test]# wc -w test.txt 

8 test.txt

[root@localhost test]# wc -m test.txt 

70 test.txt

[root@localhost test]# wc -L test.txt 

17 test.txt


查询文件中特定字符串,以及前后5行信息:
cat /etc/passwd | grep -A5 root

B是前n行,忘了是大写还是小写的
A for after
B for before

查询文件中匹配字符串的一共多少行:
grep -c ‘2016-10-02’ nohup.out

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK