The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parsing text from file ndnkyd Shell Programming and Scripting 0 04-02-2008 01:42 AM
Text File Parsing Djlethal Shell Programming and Scripting 2 02-27-2008 03:31 AM
Parsing a line in Shell Script unishiva Shell Programming and Scripting 3 11-01-2007 04:30 PM
Plz Help To convert xml file to text file using bourn shell scripts ram2s2001 Shell Programming and Scripting 0 11-09-2005 09:56 AM
Converting Text File into XML using Unix Shell Scripts Laud12345 Shell Programming and Scripting 10 02-16-2005 01:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-17-2007
th3g0bl1n
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Red face 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:

Code:

$[{"_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!

th3g0bl1n
  #2 (permalink)  
Old 10-17-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,930
Is that only those values that follow id or values that follow ids as well ?

here is a sample

Code:
sed 's/^.*\"id\":\"//g;s/\".*$//' filename > output
  #3 (permalink)  
Old 10-19-2007
th3g0bl1n
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
  #4 (permalink)  
Old 10-19-2007
th3g0bl1n
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
This is what I have;

Code:

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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0