LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-09-2007, 09:10 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
Help With RegExp.. Somedata +....+ Somedata


Hi All I am trying to parse a logfile to get the data from StringA to StringB with all the data in between..the data between StringA and StringB spreads over multiple lines example..

StringA .data data
data
data
data ..StringB

I am trying :

cat /usr/local/mylog.log | grep -E 'StringA.*StringB'

Should I use SED..? Can any provide me with an example ?

Thx for any help

Last edited by ALInux; 08-09-2007 at 09:12 AM.
 
Old 08-09-2007, 11:04 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Something like this should work:

sed -n '/StringA/,/StringB/p' infile

The above will only print what's between StringA and StringB (both are included in output).
You can use regular expressions for line ranges in sed. Instead of the 'standard' 1,4 (print lines 1 to 4) you can do /xxx/,/yyy/ where xxx and yyy are reg. expr. You can also combine them (1,/zzz/).

Hope this helps.
 
  


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
regexp help cliff76 Linux - Newbie 3 03-07-2008 02:15 PM
ls and regexp ygloo Programming 8 10-05-2006 03:50 PM
regexp stomach Linux - Software 7 02-15-2006 06:33 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 02:19 AM
regexp help ... pld Programming 1 03-15-2005 03:45 PM

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

All times are GMT -5. The time now is 11:55 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
Open Source Consulting | Domain Registration