wget和grep生成 - 参数太多了

时间:2017-04-06 15:30:45

标签: bash grep wget

我有以下代码运行wget,其中包含文件名中的单词列表,然后尝试grep文本,但继续挣扎,右后方滴答应该是因为我得到了太多的参数" #34; 另外,你认为使用Curl更好吗?

#!/usr/bin/bash

filename=$1

ip=http://172.29.46.28/

while read -r line

 do

name="$line"

if [ `wget -q -O - "$ip""$name" | grep "text"` ]
then
   echo "found"
 fi
done < "$filename"

1 个答案:

答案 0 :(得分:0)

我会更改if语句,不包括命令的输出(可能太长)。

只是做:

wget -q -O - "${ip}${name}" | grep -qs "text"

if [ $? -eq 0 ]
then
  echo "found"
fi
相关问题