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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extracting data from file using sed

Reply to Message Icon

Name: EneWolverine
Date: December 26, 2006 at 15:20:19 Pacific
OS: Ubuntu Server
CPU/Ram: AMD Athlon 768 MB Ram
Product: 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



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


whats wrong in this Find a string; print next...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Extracting data from file using sed

Need help extracting data from file www.computing.net/answers/unix/need-help-extracting-data-from-file/7836.html

Extracting lines from file using sh www.computing.net/answers/unix/extracting-lines-from-file-using-sh/7664.html

get data from file Linux www.computing.net/answers/unix/get-data-from-file-linux/4218.html