bash - 在 shell 脚本中使用 curl 时,如何消除所有额外的文本?

标签 bash shell curl

这是一个示例 ip 代理检查器 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

我怎样才能让多余的东西安静下来?

最佳答案

-s/--silent
静音模式。不要显示进度表或错误消息。使 Curl 静音。
如果此选项使用两次,第二个将再次禁用静音。

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

关于bash - 在 shell 脚本中使用 curl 时,如何消除所有额外的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22853406/

相关文章:

shell - Unix 猫 : No such file or directory error

linux - 脚本 : Is it possible to format seq to display n numbers per line?

javascript - 此 CURL 脚本的等效 Javascript 请求 header 是什么?

linux - 不带引号的表达式注入(inject) bash

bash - 寻找大文件的 uniq -c 替代品

bash - BASH_REMATCH 在 Bash 5.1 中不是只读的有什么用?

Python 子进程和 shell 输入重定向

php - cURL无法完全模拟HTTP Post

php - Moodle 语言同步

bash - 循环被 ssh 运行脚本打破