我需要comapre 7個文件Ref.txt和Jan.txt到Jun.txt並獲得匹配,並且不匹配,對於這種情況 我期待檢查Ref.txt的第二個字段,將Jan.txt的所有第一個字段設置爲Jun.txt,如果是,則打印Ref.txt(主轉儲)的所有文件, ,然後將Jan.txt的整行打印到Jun。文本。並且在Jan.txt和Jun.txt之間找不到匹配來聲明「NotFound」。awk比較7個文件,打印匹配和區別根據提起:
Ref.txt
abc 10 xxyyzz
bdc 20 xxyyzz
edf 30 xxyyzz
ghi 40 xxyyzz
ofg 50 xxyyzz
mgf 60 xxyyzz
Jan.txt
10 Jan 100
30 Jan 300
50 Jan 500
Feb.txt
Mar.txt
20 Mar 600
50 Mar 1500
Apr.txt
10 Apr 100
30 Apr 300
50 Apr 500
May.txt
10 May 200
20 May 400
40 May 800
60 May 1200
Jun.txt
20 Jun 600
50 Jun 1500
所需的輸出:
Ref.txt Ref.txt Ref.txt Jan.txt Jan.txt Jan.txt Feb.txt Feb.txt Feb.txt Mar.txt Mar.txt Mar.txt Apr.txt Apr.txt Apr.txt May.txt May.txt May.txt Jun.txt Jun.txt Jun.txt
abc 10 xxyyzz 10 Jan 100 10 Feb 200 Notfound Notfound Notfound 10 Apr 100 10 May 200 Notfound Notfound Notfound
bdc 20 xxyyzz Notfound Notfound Notfound 20 Feb 400 20 Mar 600 Notfound Notfound Notfound 20 May 400 20 Jun 600
edf 30 xxyyzz 30 Jan 300 Notfound Notfound Notfound Notfound Notfound Notfound 30 Apr 300 Notfound Notfound Notfound Notfound Notfound Notfound
ghi 40 xxyyzz Notfound Notfound Notfound 40 Feb 800 Notfound Notfound Notfound Notfound Notfound Notfound 40 May 800 Notfound Notfound Notfound
ofg 50 xxyyzz 50 Jan 500 Notfound Notfound Notfound 50 Mar 1500 50 Apr 500 Notfound Notfound Notfound 50 Jun 1500
mgf 60 xxyyzz Notfound Notfound Notfound 60 Feb 1200 Notfound Notfound Notfound Notfound Notfound Notfound 60 May 1200 Notfound Notfound Notfound
預先感謝您的回覆
謝謝你回想起來,爲您的文章的可讀性。 – Noctua
謝謝你的有趣問題。我們無聊到死。 – devnull
爲什麼在預期的輸出中沒有'4月10日100'? –