How do I silence the HEAD of a curl request while using the silent flag?

When I run the curl command and direct the data to a file, I get back the content of the site as expected.

$ curl "" > 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 "" > 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 "" > 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.

-------------Problems Reply------------

Try this:

curl --silent "" > file.txt

You need to use --silent with two dashes. Your “option” -silient (sic!) enables the -s, -i, -l, -e, -n and -t options.

-i is what includes the HTTP header.

Category:bash Views:2 Time:2019-01-12

Related post

Copyright (C), All Rights Reserved.

processed in 0.130 (s). 11 q(s)