LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2011, 05:41 PM   #16
dragomang87
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Rep: Reputation: 1

actually even with regex powerfull enough, grep shouldn't work
because to recognize the words you need to rely on the common part that is in the sides
but that is still part of the regex so it will be printed together with the word

grep is a finder not an editor, so is in the wrong category of programs for this


sed is an editor, and for this will be enough
it can also do the work of grep putting it on quiet with -n and printing only when there is a match with the p option in s program
cat file |sed -n 's/.*sourceid=\([^&]*\).*/\1/p'

so it's working even if there are mixed lines, if you have more rules for different kind of lines you can add them on sed

cat file |sed -n 's/.*sourceid=\([^&]*\).*/\1/p;s/side-left-match\(word-match\)side-right-match/\1/p'

info sed
for information on sed and regexp
 
  


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
[SOLVED] Grep -p for Linux, Trying to grep a paragraph. ohijames Linux - Newbie 5 07-22-2010 03:09 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 08:12 AM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 12:36 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 12:38 PM


All times are GMT -5. The time now is 02:30 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