Ian Arman
Ian Arman

Reputation: 93

Search for specific text within a text string using grep or awk

GET https://api.discogs.com/artists/"152450"?callback=callbackname

Please click to see output

How would I use grep or awk -F, to display the highlighted text?

I've tried with GET https://api.discogs.com/artists/"152450"?callback=callbackname | awk -F, '{ print $43$44$45$46 }'

This will return the profile text, although if I change the Discogs id "number in quotes" to 1 for example, i'm not able to return the same data

Upvotes: 0

Views: 57

Answers (2)

Ian Arman
Ian Arman

Reputation: 93

GET https://api.discogs.com/artists/"310226"?callback=callbackname | awk 'BEGIN {FS = ":" } {for (I=1;I<=NF;I++) if ($I ~ "profile") {print $(I+1)};'}

with help from Farhad

Upvotes: 0

Farhad Sarvari
Farhad Sarvari

Reputation: 1081

You can try this :

cat file |  awk 'BEGIN {FS = ":" }  {for (I=1;I<=NF;I++) if ($I ~ "profile") {print $(I+1)};'}

Upvotes: 1

Related Questions