Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ns:m.050fh のようないくつかの ID を持つファイル (file1) があります (1 行に 1 つの ID で、ここでは正規表現を使用できません)。
2番目のファイル(file2、csv、タブで区切られた)から行を出力する必要があります.2番目のファイルの最初の列=最初のファイルのIDです。
awkまたはgrepで可能ですか?
(疑似コード) のようなもの:
awk -F'\t' '$1 == $(file1)' file2
これを試して:
awk -F'\t' 'NR==FNR{a[$0];next} $1 in a' file1 file2
file1 は ID ファイルです。
上記の行は、id が file1 に存在する file2 からすべての行を出力します。