文書、
.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
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
ベストアンサー1
多くのツールが便利です。
-n
ofがgrep
あなたが探しているものです。grep -n 'bla' file
または
awk
:awk '/bla/{print NR":"$0}' file
または
perl
:perl -ne 'print $.,":",$_ if /bla/' file
または
sed
:sed '/bla/!d;=' file |sed 'N;s/\n/:/'