Parsing text from one line with shell scripts

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Parsing text from one line with shell scripts
# 1  
Old 10-17-2007
Power 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! Smilie

# 2  
Old 10-17-2007
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

# 3  
Old 10-19-2007
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,

# 4  
Old 10-19-2007
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?

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing Command Line Arguments In C shell script

]I have a string like "/abc/cmind/def/pq/IC.2.4.6_main.64b/lnx86" and this string is given by user. But in this string instead of 64b user may passed 32 b an i need to parse this string and check wether its is 32b or 64 b and according to it i want to set appropriate flags. How will i do this... (11 Replies)
Discussion started by: codecatcher
11 Replies

2. Shell Programming and Scripting

Parsing line with name:value pairs in shell script

HI , I have the following type of lines in a file and need to create a csv file that can be bcp'ed into a db The problem that I have is the delimited of the <name :value> is a space but some of the values in the pairs have space . eg msg_src_time:03/05/13 10:40:17.919 Need sugesstions on... (9 Replies)
Discussion started by: tasmac
9 Replies

3. Shell Programming and Scripting

Help/Advise on parsing these line of text

Hi, Can anyone please advise how do I parse the following line of strings? 14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(\Ora6i\BIN\ifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST= *... (10 Replies)
Discussion started by: newbie_01
10 Replies

4. Shell Programming and Scripting

XML-Text Parsing Using shell scripting

HI Guys, I have to parse below xml file :- <xn:SubNetwork id="ONRM_ROOT_MO_R"> <xn:MeContext id="LP101"> <xn:ManagedElement id="1"> <xn:VsDataContainer id="1"> <xn:attributes> ... (8 Replies)
Discussion started by: asavaliya
8 Replies

5. Homework & Coursework Questions

Problem with Shell Scripts deleting text in files.

Me and a friend are working on a project, and We have to create a script that can go into a file, and replace all occurances of a certain expression/word/letter with another using Sed. It is designed to go through multiple tests replacing all these occurances, and we don't know what they will be so... (1 Reply)
Discussion started by: Johnny2518
1 Replies

6. Solaris

XML to Text file Parsing Using shell scripting

Hi, I want to parse an XML File using Shell Script preferably by using awk command, I/P file is : <gn:ExternalGsmCell id="016P3A"> <gn:attributes> <gn:mnc>410</gn:mnc> <gn:mcc>310</gn:mcc> <gn:lac>8016</gn:lac> ... (2 Replies)
Discussion started by: tech_frk
2 Replies

7. Shell Programming and Scripting

XML to Text file Parsing Using shell scripting

Hi folks, Need some help with XML to text file parsing , the following is the content of the XML File. <xn:SubNetwork id="SNJNPRZDCR0R03"> <xn:MeContext id="PRSJU0005"> <xn:VsDataContainer id="PRSJU0005"> <xn:attributes> ... (6 Replies)
Discussion started by: tech_frk
6 Replies

8. Shell Programming and Scripting

Parsing and filtering multiline text into comma separated line

I have a log file that contains several reports with following format. <Start of delimiter> Report1 header Report1 header continue Report1 header continue Record1 header Record1 header continue Record1 header continue field1 field2 field3 field4 ------... (1 Reply)
Discussion started by: yoda9691
1 Replies

9. Shell Programming and Scripting

Parsing a line in Shell Script

I have record line somthing like below with first line showing char spacing not real record line 1 | 2 | 3rd Field--------------|-4th field--| This is charcatersapcing of line DF20000000000000000130.7890000000750 I shoudl get two line from above line 1st line should 1 | 2 | 3rd... (3 Replies)
Discussion started by: unishiva
3 Replies

10. Shell Programming and Scripting

Converting Text File into XML using Unix Shell Scripts

Hi everyone, If someone out there could help me out with this problem. I would really appreciate it. I am trying to convert a file into xml format using Unix shell scripts. The file has fields with each field having a certain number of bytes, but the fields are not delimited by anything... (10 Replies)
Discussion started by: Laud12345
10 Replies
Login or Register to Ask a Question