0
我有2個文件 文件1包含了我需要到grep 例如模式列表:2列表使用grep文件
abc
bcd
def
文件2中包含的文件名以絕對路徑 例如,沿着:
/prod/users/abc/username/filename1.dat
/prod/users/abc/username/filename2.dat
/prod/users/abc/username/filename3.dat
我到grep
abc in /prod/users/abc/username/filename1.dat
bcd in /prod/users/abc/username/filename2.dat
def in /prod/users/abc/username/filename3.dat
任何人都可以在這裏幫助我與UNIX代碼。 以下不起作用
for i in `cat file2`
do
for j in `file1`
do
cat -n $i| grep $j >> file_final.txt
done
done
避免使用舊的和不贊成使用的反斜槓,使用括號如下:'for i in $(cat file2)'' – Jotne 2015-03-25 18:08:16