在當前目錄中,我想打印文件名和內容。 我可以xargs與多個命令
find . | grep "file_for_print" | xargs echo
find . | grep "file_for_print" | xargs cat
單獨打印的文件名或內容,但我要的是打印他們這樣在一起:
file1
line1 inside file1
line2 inside file1
file2
line1 inside file2
line2 inside file2
我讀xargs with multiple commands as argument 並試圖
find . | grep "file_for_print" | xargs -I % sh -c 'echo; cat;'
但沒有按」工作。 我不熟悉xargs,所以不知道「-I%sh -c」是什麼意思。 任何人都可以幫助我嗎?謝謝!
試試這個.....我想這應該幫助,「找|。grep的‘file_for_print’| xargs的多個」 – nsd