views:

26

answers:

1

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?

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

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

Note, use GNU awk. (gawk)

ghostdog74
I'm getting this: awk: invalid -v option
Elijah W.
what OS are you using?
ghostdog74
10.6 I think------
Elijah W.
I'm getting this now: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 4127 100 4127 0 0 1272 0 0:00:03 0:00:03 --:--:-- 3745Mac5:~ elijahwood$
Elijah W.
I asked you what OS. Linux? solaris? Ubuuntu? Fedora? etc... I don't know what is 10.6. Its just a number to me.
ghostdog74
ohh mac osx ----
Elijah W.
Check your awk version. If you don't have gawk, consider installing it: http://gawk.darwinports.com/. Also, check if you are actually getting something back using curl (without awk). Show the curl output in your question
ghostdog74