Shell

【shell】shell小脚本

2022-06-23  本文已影响0人  Bogon

1. xargs  -I {} 的使用

$  find   /path/to   -name  "*.sh"  -type f  |  xargs  -I  {}  sh {}  restart'

$  find   /path/to   -name  "*.sh"  -type f  |  xargs  -I  {}  basename {} '

2.  awk想打印除指定列外的所有列

# awk  '{ $1="";  print $0 }'      test.txt

# awk  '{ $NF="";  print $0 }'    test.txt

# awk '{ for(i=1; i<=1; i++){ $i="" }; print $0 }' test.txt

# awk '{for(i=1; i<=5; i++){$i=""}; print$0}' test.txt

注意: 字段改为空白,但是还是字段依然存在,所以输出的时候仍然会输出FS,即空格。

3. cut 做字段截取

#  cut   -d   '_'    -f3    file.txt

以 _ 为分隔符,取第3列

上一篇 下一篇

猜你喜欢

热点阅读