shell脚本-两个list查找匹配项

#!/bin/bash

search_list='xx/search_list.txt'
list='xx/revise_list.txt'
result='xx/result.txt'

# 逐行读取list文件
while IFS= read -r line; do
  # 在search_list文件中查找匹配项
  match=$(grep -F "$line" "$search_list")
  
  # 如果有匹配项,则写入到result文件,否则写入not match
  if [ -n "$match" ]; then
    echo "match ${line}" >> "$result"
  else
    echo "not match ${line}" >> "$result"
  fi
done < "$list"

  

posted @ 2023-12-05 15:24  容_易  阅读(56)  评论(0)    收藏  举报