LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-17-2009, 08:23 AM   #1
wolfipa
LQ Newbie
 
Registered: May 2004
Location: Austria
Distribution: Fedora Ubuntu OpenSuse
Posts: 26

Rep: Reputation: 15
search string in text and print string


Hi,

I try to parse html data and search for certain strings.
The search string should be
SIxxxxx
or
MFxxxxx
where xxxxx is any number from 0 to 99999

I've tried many different solutions (using cut to get the correct column,...) but I have more than one html document and the layout slightly differs.

At the end I just need the found string. e.g. SI33001

Thanks for any hint!
 
Old 09-17-2009, 08:42 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,175

Rep: Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629Reputation: 2629
You need something more generic than "cut". Try this
Code:
grep -Eo "(SI|MF)[[:digit:]]{5}" input.file
See the manpage.
 
Old 09-17-2009, 09:03 AM   #3
wolfipa
LQ Newbie
 
Registered: May 2004
Location: Austria
Distribution: Fedora Ubuntu OpenSuse
Posts: 26

Original Poster
Rep: Reputation: 15
Hi syg00
this just works like a charm .. but only on my linux box.

The grep command on the system I need to run this doesn't know the "o" switch ... any other idea?

Thanks very much for the great hint.
 
Old 09-17-2009, 09:43 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by wolfipa View Post
Hi syg00
this just works like a charm .. but only on my linux box.

The grep command on the system I need to run this doesn't know the "o" switch ... any other idea?

Thanks very much for the great hint.
What is the other system? since you are using GREP, I assume that it is some sort of *nix.

What does the man page say?
 
Old 09-17-2009, 09:50 AM   #5
wolfipa
LQ Newbie
 
Registered: May 2004
Location: Austria
Distribution: Fedora Ubuntu OpenSuse
Posts: 26

Original Poster
Rep: Reputation: 15
hi,
you know as400? I'm running the command in some kind of *nix environment.
Anyhow, I just managed to get the "grep" command from AIX - and this one is capable of running the -Eo option.
Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to search for a string in a text file using wildcards(*,?) tnjones Programming 2 08-23-2008 08:04 AM
Can you make search ...search a string in a link....a url...a web address aus9 LQ Suggestions & Feedback 4 04-16-2008 10:37 AM
C....Search a string for a string Scrag Programming 4 06-14-2004 05:15 PM
[c++] Search in a string hylke Programming 5 06-14-2004 12:20 PM
How do you search for a string? kau2 Linux - General 2 01-05-2004 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration