在shell脚本中使用curl时,如何安静所有额外的文本?

时间:2014-04-04 04:11:20

标签: bash shell curl

这是一个示例ip proxy checker shell脚本:

#!/bin/sh
while read IP
do
    CURL=$(curl -x http://$IP -L http://icanhazip.com)
    echo "$CURL"
done < ip.txt

但不是简单的结果,而是:

0.0.0.0
1.1.1.1

我明白了:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
0.0.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
1.1.1.1

我怎样才能安抚额外的东西?

1 个答案:

答案 0 :(得分:4)

-s/--silent

无声模式。不显示进度表或错误消息。使卷曲静音。 如果此选项使用两次,则第二次将禁用静音。

CURL=$(curl -s -x http://$IP -L http://icanhazip.com)