curl -i -v --silent \
-H "Content-Type: application/json" \
-d '
{some data>
}' \
https://foo 2>&1 |grep -w '^boo:' }
I receive
boo: foo
I only want the foo string without whitespace
You don't need grep + awk . awk can do the grep job without any problem.
for a file like this:
$ cat file1
too: soo
boo: foo
boofoo: wow
boof: nonono
koo: loo
This works fine:
$ awk '/^boo:/{print $2}' file1
foo
awk by default uses whitespace as fields delimiter, so you don't need -F' ' also
In your case just pipe curl to awk: curl ....|awk '/^boo:/{print $2}'
PS: You can also use gnu grep if available like this: grep -Po '^boo: \K.*' file1
jsonis safer as grep.