objectiveccoder001
objectiveccoder001

Reputation: 3031

parsing a curl in the command line

I have this:

curl -H \"api_key:{key}\" http://api.wordnik.com/api/word.xml/dog/definitions

How do I parse this (within the commandline) to make it take whatever's in between <text> and </text> in this page?

Upvotes: 0

Views: 1582

Answers (1)

ghostdog74
ghostdog74

Reputation: 342413

$ curl ....... | awk -vRS="</text>" '/<text>/{ gsub(/.*<text/,""); print "->"$0}'

$ curl ....... | awk 'BEGIN{RS="</text>"}/<text>/{ gsub(/.*<text/,""); print "->"$0}'

Note, use GNU awk. (gawk)

Upvotes: 2

Related Questions