内部循环中grep不起作用

时间:2017-08-03 16:52:53

标签: linux bash for-loop grep

Grep似乎在循环中不起作用。

prashant@prashant-Inspiron-3542:~/Downloads/files_for_script$ grep "$ GR" firstFIle | cut -b3-
GR:NSM1_base_to_diffuser
GR:NSM2_base_to_diffuser
GR:FSin_not_imposed_to_FS_out
GR:Diffuser_to_FSin_not_imposed
GR:FSin_imposed_to_FS_out
GR:FSin_imposed_to_not_imposed
GR:FS_out_to_MLI
GR:FSout_to_OSR


prashant@prashant-Inspiron-3542:~/Downloads/files_for_script$ grep GR:NSM1_base_to_diffuser secondFile 

Groupi:    20.00   6.0355E+01    5.0409E+02    NSM1_base - GR:NSM1_base_to_diffuser - Primary Region
 Groupj:    20.00   0.0000E+00    2.4418E+03    DIFFUSER - GR:NSM1_base_to_diffuser - Secondary Region

但是当我在for循环中使用它时,它没有显示任何输出。

prashant@prashant-Inspiron-3542:~/Downloads/files_for_script$ for line in `grep "$ GR" firstFIle | cut -b3-`; do grep $line secondFile; done
prashant@prashant-Inspiron-3542:~/Downloads/files_for_script$ 
prashant@prashant-Inspiron-3542:~/Downloads/files_for_script$ 

我似乎不明白我在这里做错了什么。

0 个答案:

没有答案