Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I quiet all the extra text when using curl within a shell script?

Tags:

bash

shell

curl

Here's an example ip proxy checker shell script:

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

But instead of a simple result like:

0.0.0.0
1.1.1.1

I get:

  % 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

How can I quiet the extra stuff?

like image 909
Ryan Avatar asked Mar 21 '23 00:03

Ryan


1 Answers

-s/--silent

Silent mode. Don't show progress meter or error messages. Makes Curl mute. If this option is used twice, the second will again disable mute.

CURL=$(curl -s -x http://$IP -L http://icanhazip.com)
like image 137
Ryan Avatar answered Apr 26 '23 04:04

Ryan