[英]How to select from the output of grep?
I want only to extract the date from the name of this file: 我只想从这个文件的名称中提取日期:
So I did this: 所以我这样做了:
echo HNR.L04.C07.ldd.T2018050.BG.nc.nc |grep -o '[0-9]\+'
I got this: 我懂了:
04
07
2018050
Now I want to select the third line? 现在我想选择第三行? any idea?
任何想法?
You can get the firthd line of output with: 您可以通过以下方式获得firthd输出线:
set -n 3p
You can get the last line of output with: 你可以得到最后一行输出:
tail -n 1
Ex: 例如:
echo HNR.L04.C07.ldd.T2018050.BG.nc.nc | grep -o '[0-9]\+' | sed -n 3p
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.