shell特殊符号cut命令
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段以冒号为分隔符
cat /etc/passwd |head -2 |cut -c 4 显示/etc/passwd显示前两行,指定第4个字符
8.11 sort_wc_uniq命令
sort /etc/passwd sort默认按照阿斯玛排序
head /etc/passwd > 2.txt 显示/etc/passwd前10行重定向给2.txt
特殊符号 数字 字母 星号
sort -n 2.txt 以数字排序,字符或者特殊符号都会认为是0
sort -rn 为倒序
wc -l 统计行数
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 追加
tr 替换字符
echo “aminglinux” |tr ‘[zh]’ ‘[AL]’
split -b 100m bigfile 切割成100m一个文件
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特殊符号下
for i in seq 1 10
; do echo $i; done