Parsing text from one line with shell scripts

Hi Gurus!

I wonder if anyone can help me, I'm sure you guys can.

I have a text file which contains a lot of data on the one line as follows:


$[{"_field0":"blah","_field1":"blah","_field2":"blah","_field3":"blah","field4":"blah","field5":blah,"field5":blah},{"html":1,"type":"bingo","bingo":"Results <span class='b'>1<\/span>-<span class='b'>50<\/span> of <span class='b'>497<\/span> for <span class='b'>match<\/span>"},{"id":"2549425,12087370,6013917","ids":62,"type":"record","name":"blah - smashing"},{"id":"4736260,7981901,5614559","ids":52,"type":"record","name":"blah - sorry"}

What I need to do is pull all of those id values out (eg 2549425) and write them to a list in a text file.

Any help would be greatly appreciated! :confused:

th3g0bl1n

Is that only those values that follow id or values that follow ids as well ?

here is a sample

sed 's/^.*\"id\":\"//g;s/\".*$//' filename > output

Thanks matrix,

That worked, I'm also looking to extract the 'blah - smashing' and 'blah - sorry' into a list format;

blah - smashing
blah - sorry

I guess I can tinker with what you've provided to achieve that.

Thanks again,

g0bl1n

This is what I have;


sed 's/^.*\"name\":\"//g;s/\".*$//' input > output

but this only outputs the last line, e.g.

blash - sorry

Any ideas how I can get it to read the whole line? Perhaps I need to break it up first?

G0bl1n