我想從一組文件中找到字符串Execution has sterted
的出現,
說明存在於目錄/home/abc/output/
中的三個文件。如何捕獲文件中的特定字符串
對於這一點,我目前使用下面的命令:
grep "Execution has sterted" /home/abc/output/*
它輸出:
/home/abc/output/file1:line containing "Execution has sterted"
/home/abc/output/file1~:line containing "Execution has sterted"
/home/abc/output/file2:line containing "Execution has sterted"
/home/abc/output/file2~:line containing "Execution has sterted
/home/abc/output/file3:line containing "Execution has sterted"
/home/abc/output/file3~:line containing "Execution has sterted"
即使3個文件都在那裏,輸出由6行,與原來的路徑(s)和其他路徑以~
結尾,如上所示。
我希望它顯示原始路徑的發生,而不是~
。
如何做到這一點?
謝謝大家,
它適合我。
我的實際查詢是,通過冠詞job perticular作業將運行,並將生成說3個日誌文件。每個日誌文件將包含語句,我需要catpure 2語句說grep「執行已執行」和「執行成功完成「。 一旦我得到兩個以上的陳述,然後只有我可以順利完成作業成功(因爲一些時間工作卡在某一點)
這是如何通過腳本來完成的? 我應該得到消息作業已完成或作業失敗
'ls'的輸出是什麼?我傾向於認爲你在某些時候複製了你的文件,這些'〜'文件確實存在。除非存在這樣的文件,否則'grep'不會寫'/ home/abc/output/file1〜'。 – dimo414