For some reason the output always gets printed to the terminal, regardless of whether I redirect it via 2> or > or |. Is there a way to get around this? Why is this happening?>
I found the same thing: curl by itself would print to STDOUT, but could not be piped into another program.
At first, I thought I had solved it by using xargs to echo the output first:
curl -s ... | xargs -0 echo | ...
But then, as pointed out in the comments, it also works without the xargs part, so -s
(silent mode) is the key to preventing extraneous progress output to STDOUT:
curl -s ... | perl -ne 'print $1 if /([^<]+)/'
The above example grabs the simple
content (containing no embedded tags) from the XML output of the curl statement.