shell命找到某个文件夹里有某个关键字

方式1

#!/bin/bash

for file in `find / -name "*.yaml"`; do
  if grep -q "uat-wallet-pay.exchangs.top" $file; then
   echo $file >> output.txt
 fi
done

方式 2

# 获取参数
key="$1"

# 查找文件
for file in `find / -name "*.yaml"`; do
  if grep -q "$key" $file; then
    echo $file >> output.txt
  fi
done

#运行
#./xx.sh top

你可能感兴趣的:(system,Shell,ssh)