Nai*_*ita 10 shell awk shell-script text-processing
文件,
.false alarm is bla no. 11
.no alarm generated is bla
.application will be killed is bla wall command
.doc file is document file with .doc extension
.no authority for this selection bla
Run Code Online (Sandbox Code Playgroud)
现在我想在我的输出文件中打印只包含单词的行bla
(或者它也可能是数字)
输出将是这样的,
1 .false alarm is bla no. 11
2 .no alarm generated is bla
3 .application will be killed is bla wall command
5 .no authority for this selection bla
Run Code Online (Sandbox Code Playgroud)
jim*_*mij 19
许多工具可以派上用场:
-n
的grep
正是你正在寻找的。
grep -n 'bla' file
Run Code Online (Sandbox Code Playgroud)或者awk
:
awk '/bla/{print NR":"$0}' file
Run Code Online (Sandbox Code Playgroud)或者perl
:
perl -ne 'print $.,":",$_ if /bla/' file
Run Code Online (Sandbox Code Playgroud)或者sed
:
sed '/bla/!d;=' file |sed 'N;s/\n/:/'
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
43915 次 |
最近记录: |