I'm trying to get only first line of the curl
command output. (Sorry if this is confusing)
Let's say, for an instance, i run simply:
# curl http://localhost
<!-- This is the hidden line i want to grab. -->
<!DOCTYPE html>
<html>
<head>
..
..
What to do if i want the very first line of the output here, which is:
<!-- This is the hidden line i want to grab. -->
I've tried things like this, but no luck yet:
# curl http://localhost | head -n 1
# curl http://localhost | sed -n '1!p'
.. etc. All gives me rubbish outputs, like this:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<!-- This is the hidden line i want to grab. -->
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (23) Failed writing body (173 != 1763)
It's not the output as expected as mentioned above:
<!-- This is the hidden line i want to grab. -->
Any experts here please =(
curl -s http://example.com/ | head -n1
should work correctly, unless your output is compressed.rubbish outputs
means. Thanks.-s
parameter to mute any progress output (rubbish). This still goes to stderr, so it won't be saved into the file if you redirect it somewhere.