shell特殊符号cut命令

shell特殊符号

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段以冒号为分隔符
shell特殊符号

cat /etc/passwd |head -2 |cut -c 4 显示/etc/passwd显示前两行,指定第4个字符shell特殊符号


8.11 sort_wc_uniq命令

shell特殊符号

sort /etc/passwd sort默认按照阿斯玛排序
shell特殊符号

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

特殊符号 数字 字母 星号

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

shell特殊符号

sort -rn 为倒序

shell特殊符号

wc -l 统计行数

shell特殊符号

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 追加
shell特殊符号

tr 替换字符

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

shell特殊符号

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

shell特殊符号

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特殊符号下

shell特殊符号

for i in `seq 1 10`; do echo $i; done
shell特殊符号

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

相关文章:

  • 2021-12-23
  • 2021-12-05
  • 2021-12-23
  • 2022-01-17
  • 2022-12-23
  • 2021-10-12
  • 2021-04-17
  • 2022-12-23
猜你喜欢
  • 2021-06-23
  • 2022-12-23
  • 2021-04-20
  • 2022-01-22
  • 2021-10-15
  • 2022-01-30
相关资源
相似解决方案