Computing.Net > Forums > Unix > Extracting data from file using sed

Extracting data from file using sed

Reply to Message Icon

Original Message
Name: EneWolverine
Date: December 26, 2006 at 15:20:19 Pacific
Subject: Extracting data from file using sed
OS: Ubuntu Server
CPU/Ram: AMD Athlon 768 MB Ram
Model/Manufacturer: Targa
Comment:

Hi all,

I've just started to work with shell scripting and sed today. I'm trying to figure out how I can extract data from a file. Basically the file I want to extract data is a streaminfo file from my satellite receiver box (dreambox) and the file structure looks like this:

[html tags]
[html tags]VPID:[html tags]123h[html tags]APID[html tags]:[html tags]678b
[html tags]

That's the gist of it. I've found out how to strip the html tags from the file using sed but actually I don't really even need to do that.

What I want to do is for instance search for the string "VPID" in the file above and then extract the sequence of numbers/letters that follows that. I need to extract it in the form of a variable as I'm running this from a shell script and I want to use that extracted data later on in the shell script.

If I strip the html tags then the file looks like:

VPID: 123h APID: 678b

I've not quite got the hand of regex yet and I was wondering if there's a simple way to go about getting this data out of the file.

Any help would be greatly appreciated.

Thanks in advance,

The Wolverine :D


Report Offensive Message For Removal








Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Extracting data from file using sed

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge