shell脚本中获取指定行指定列来进行操作


title: shell脚本中获取指定行指定列来进行操作
date: 2019-11-27 16:27:49

tags:

1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9

1、获取第2-5行
sed -n '2,5p' testfile

2、获取2-3列
awk '{print \(2 \)3}' testfile
可选cut(忘了吧,别记太多,脑袋不够用啊)

cat test123 | awk '{print \(2,\)3}' | sed -n '4,5p' | xargs -n 1 echo

猜你喜欢

转载自www.cnblogs.com/Alpes/p/shell-jiao-ben-zhong-huo-qu-zhi-ding-xing-zhi-ding.html
今日推荐