2016-05-08 23 views
1

有沒有在grep命令之後添加回顯的方法?在grep搜索後添加回顯

例如,如果我運行此:

grep -R $id && echo appearances in database 

輸出是

listofids.txt:226526658 201 
appearances in database 

有沒有辦法得到它顯示爲這樣:

listofids.txt:226526658 201 appearances in database 

我曾嘗試一些想法浮現在腦海中,但沒有任何成效,例如:

echo "" grep -R $id "appearances in database" 

我知道這行不通,但我認爲這值得一試。

回答

3

這應該這樣做:

echo "$(grep -R $id) appearances in database"