bash. , , :
$ text="Infosome - infotwo: (29333) - data-info-ids: (33389, 94934)"
$ result="${text/*(}"
$ echo ${result//[,)]}
33389 94934
This uses the shell extension "parameter extension" (which you can find on the bash man page) to remove the line in the same way as with tr. Strictly speaking, quotation marks in the second line are not needed, but they help with StackOverflow syntax highlighting. :-)
You can alternately make this a bit more flexible by looking for the field you are interested in. If you use GNU awk, you can specify RS with a few characters:
$ gawk -vRS=" - " -vFS=": *" '
{ f[$1]=$2; }
END {
print f["data-info-ids"];
}' <<<"$text"
I prefer this method because it actually interprets the input so that it is structured text representing some kind of array.
source
share