如何在循环中匹配仅找到的关键字

时间:2019-07-13 13:13:53

标签: bash

我正在比较2个文件, 我想显示仅匹配的行,如果没有匹配则说不匹配

for f  in `cat faulty_lun_wwid_only.txt`
#for f  in `cat good_lun_wwid_only.txt`
do
  echo "First Loop - LUN from faulty_lun_wwid_only.txt $f"
  #echo $f
  echo "-----"
    for i in `cat multipath_onlywwid.txt | grep "$f"`
      do
        #  echo $?
          echo "Found the match"
          echo "$i"

      done
done

它像这样显示

Found the match
  3600601601a003200e6efb15f8442e511
  First Loop - LUN from faulty_lun_wwid_only.txt 3600601601a003200de91a33f8442e511
  -----
  First Loop - LUN from faulty_lun_wwid_only.txt 3600601601a0032006019ab577b38e211
  -----

我想做的是,  如果未找到匹配项,则会显示未找到伦编号“ $ f”

0 个答案:

没有答案