shell特殊符号

shell特殊符号cut命令

ef322b72ae1adbf43a8cd985350ab9e2f65.jpg

cat /etc/passwd |head -2 |cut -d ":" -f 1 显示/etc/passwd显示前两行,截取第一段以冒号为分隔符
cat /etc/passwd |head -2 |cut -d ":" -f 1,2 显示/etc/passwd显示前两行,截取12段以冒号为分隔符
cat /etc/passwd |head -2 |cut -d ":" -f 1-3 显示/etc/passwd显示前两行,截取123段以冒号为分隔符
2ddac9e7ac976305e2d015ea544609fa922.jpg

cat /etc/passwd |head -2 |cut -c 4 显示/etc/passwd显示前两行,指定第4个字符4124652021b188e10dcb77770692ac681c7.jpg


8.11 sort_wc_uniq命令

35c13e42e1408f277aae919d645d35d055c.jpg

sort /etc/passwd sort默认按照阿斯玛排序
2c3e8e1168e471f6dc9ff978fa7ae6b5772.jpg

head /etc/passwd > 2.txt 显示/etc/passwd前10行重定向给2.txt

特殊符号 数字 字母 星号

sort -n 2.txt 以数字排序,字符或者特殊符号都会认为是0

cb48e7b2ebfde51786ca058d18cabd24801.jpg

sort -rn 为倒序

55a0eb07553e5946d62d226ae329e25658a.jpg

wc -l 统计行数

e91e169b54f4746cb34c19fe35729fb9493.jpg

wc -m 统计字符数

cat -A 查看文件所有内容

wc -w 统计词,以空格空白字符做为分隔符

uniq 文件名 去重

sort 文件名 |uniq -c 先排序,再去重,-c统计有多少个


8.12 tee_tr_split命令

sort 2.txt  |uniq -c |tee a.txt tee重定向,并且把管道前面的内容打印到屏幕上

sort 2.txt  |uniq -c |tee -a a.txt   tee -a 追加
cd2876c2b456ba9a74b758d3161b9188d14.jpg

tr 替换字符

echo "aminglinux" |tr '[zh]' '[AL]'

3c6663b2bf3fdc75cd356be3210b75b3241.jpg

split -b 100m bigfile 切割成100m一个文件

424c2e9d0fd2490e5592f3c364577d2d70b.jpg

split -b 100 bigfile切割成100个字节一个文件

split -l 1000 bigfile 切割成1000行一个文件

find /etc/ -type f -name "*conf" -exec cat {} >> a.txt \;

mv a.txt test/ 移动a.txt到test目录
split -b 1000b a.txt 切割a.txt文件1000b一个

du -sb * 查看所有文件大小以b为单位

split -b 1000b a.txt abc 指定切割文件前缀


8.13 shell特殊符号下

081921_PZ8a_3804239.png

for i in `seq 1 10`; do echo $i; done
2e7e6d65cdc7e5d42dfb1e160adc8c14dec.jpg

转载于:https://my.oschina.net/u/3992081/blog/2870517

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值