Linux基础--高级命令

1.颠倒

[root@lxy ~]# tac /etc/passwd #上下颠倒

[root@lxy ~]# rev /etc/passwd #左右颠倒

2.统计 

[root@lxy ~]# wc -l /etc/passwd  #统计行数 或者-c

[root@lxy ~]# wc -w aa.txt #统计单词数

[root@lxy ~]# wc -w aa.txt #统计字符

3.排序 

[root@lxy ~]# sort -n aa.txt -n 按整个数字排序

[root@lxy ~]# sort -nr aa.txt -r 降序

[root@lxy ~]# sort -nru aa.txt -u 去重

4.去重

默认连续相同行

[root@lxy ~]# sort aa.txt | uniq -c -c 求重复次数

[root@lxy ~]# sort aa.txt | uniq -d -c 只显示重复行

[root@lxy ~]# sort aa.txt | uniq -u -u 显示不重复的行

5.过滤 

[root@lxy ~]# grep root /etc/passwd
[root@lxy ~]# grep -A 2 root /etc/passwd     -A  匹配行后两行
[root@lxy ~]# grep -B 2 root /etc/passwd    -B   匹配行前两行
[root@lxy ~]# grep -C 2 root /etc/passwd   -C   前后2行
[root@lxy ~]# grep -n root /etc/passwd      -n  显示行号
[root@lxy ~]# grep -i root /etc/passwd      -i  忽略大小写
[root@lxy ~]# grep -v root /etc/passwd    -v  取反
[root@lxy ~]# grep -x root /root/aa.txt      -x  完全匹配
[root@lxy ~]# grep -rl hostname /etc/   -r  递归  -l 列出文件名

6.剪切

[root@lxy ~]# cut -d':' -f 1 /etc/passwd 第一个字段

[root@lxy ~]# cut -d':' -f 1-3 /etc/passwd 第1-3字段

[root@lxy ~]# cut -d':' -f 1,3-5 /etc/passwd 第1, 3-5字段

[root@lxy ~]# cut -c 1 /etc/passwd 取第一个字符

[root@lxy ~]# cut -c 1-10 /etc/passwd

[root@lxy ~]# cut -c 1,5-10 /etc/passwd

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值