grep还是awk? :在两个字段中查找类似的子字符串和输出

时间:2015-11-29 15:14:32

标签: grep output field

我有两个文件,我想在file2中找到file1的字符串作为子字符串, 但是想要结果的输出(当匹配时)包含两个字段中的两个字符串除以':' 所以我的匹配输出有" file1string:file2string "

实施例 档案1

464697uifs4h44yy
48oo895i6iu8gg11
j4h5y7yu4g655h44
jyyuthvcxx22zerc

文件2

j4h5y7yu4g655h447ijj651cvpijgtkk
strxzdokui464697uifs4rdffgjfudjh
kjhbdfgfx1154m87gjgbgcsqubyu6u3k
gfhgysj4h5y7yu4g655h44jkhgfhhfhu

期望输出

j4h5y7yu4g655h44:j4h5y7yu4g655h447ijj651cvpijgtkk
j4h5y7yu4g655h44:gfhgysj4h5y7yu4g655h44jkhgfhhfhu

j4h5y7yu4g655h44:j4h5y7yu4g655h44 7ijj651cvpijgtkk 的 j4h5y7yu4g655h44 :gfhgys的 j4h5y7yu4g655h44 jkhgfhhfhu

我用过:

fgrep -f file1 file2 >output

但这仅提供了文件2的结果

0 个答案:

没有答案