When I run the curl command and direct the data to a file, I get back the content of the site as expected.
$ curl "www.site.com" > file.txt $ head file.txt Top of site ...
However, this command shows a progress bar, which I do not want:
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 328k 100 328k 0 0 467k 0 --:--:-- --:--:-- --:--:-- 467k
I can silence the progress bar by passing the
-silent flag, but then my file output will have head content attached:
$ curl -silient "www.site.com" > file.txt $ head file.txt HTTP/1.1 200 OK Content-Security-Policy: default-src 'none' X-XSS-Protection: 1; mode=block X-Frame-Options: deny X-Content-Type-Options: nosniff Strict-Transport-Security: max-age=31536000 ETag: "29647904ffa6a6b36cf3483b325138cab9447a13" Content-Type: text/plain; charset=utf-8 Cache-Control: max-age=300 Content-Length: 335978
How can I silence both the progress bar and avoid getting head content sent to the file?
Based on the provided flags, it seems like I can only get one or the other.
This is what I'm doing right now to solve the problem, but I'm not sure if it's a good idea to pipe the progress bar and possibly any errors into /dev/null.
curl "www.site.com" > file.txt 2> /dev/null
The reason I don't think this is a good idea is because it may interfere with the actual errors that I care about. I'd like to utilize the
silent flag if that's what it was intended for.
I've also tried all the same commands using the
-o to output to a file, but to no prevail.
curl --silent "www.site.com" > file.txt
You need to use
--silent with two dashes. Your “option”
-silient (sic!) enables the
-i is what includes the HTTP header.