對不起,這個問題的標題是有點混亂,但我想不出其他的東西。 我試圖做這樣的事情在不同的文件中grep「cat命令的輸出 - 每一行」
cat fileA.txt | grep `awk '{print $1}'` fileB.txt
的fileA包含100線,而FILEB包含100萬線。
我想要的是從fileA獲得id,grep在不同的file-fileB中的id並打印該行。
e.g fileA.txt
1234
1233
e.g.fileB.txt
1234|asdf|2012-12-12
5555|asdd|2012-11-12
1233|fvdf|2012-12-11
預計產量
1234|asdf|2012-12-12
1233|fvdf|2012-12-11
+1這應該是可以接受的答案,例如'grep -f'會無意中匹配諸如'1234'和'11234'之類的東西。 – Steve
@Kent你會介意解釋'NR == FNR {a [$ 0]; next;} $'1'在' – priyank
我試圖弄清楚我是否想在特定列中執行grep ... grep -f wont工作。 – priyank