使用 grep 或 awk 在文本字符串中搜索特定文本

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

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

请点击查看 output

如何使用 grepawk -F, 来显示突出显示的文本?

我试过 GET https://api.discogs.com/artists/"152450"?callback=callbackname | awk -F, '{ print }'

这将 return 配置文件文本,但如果我将 Discogs id“引号中的数字”更改为 1,例如,我无法 return 相同数据

你可以试试这个:

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

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

在 Farhad 的帮助下