The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh pattern matching ripat Shell Programming and Scripting 5 02-10-2008 04:44 PM
help need for pattern matching HIMANI UNIX for Dummies Questions & Answers 10 01-22-2008 07:30 AM
Pattern Matching op4_u Shell Programming and Scripting 10 07-18-2006 12:30 AM
Pattern matching sed leemjesse Shell Programming and Scripting 3 03-23-2005 04:06 AM
Pattern Matching danhodges99 UNIX for Dummies Questions & Answers 2 02-27-2003 03:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-14-2005
nymus7 nymus7 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 47
pattern matching and print with sed

Hi
It is possible with sed to print a pattern within a line matching regexp?
So, the line looks like : 19:00:00 [56434] blablablabla jobid 2345 <2>
the regexp is "jobid 2345" and the pattern is 56434.
That the code for find the line:
Code:
sed -n"/jobid 2345/p"
I've tries that but it doesn't run
Code:
sed -n"/jobid 2345/,/\[.*\]/p"
But how to include in my code the right expression to print only the pattern 56434 from that line?
I could perhaps use other utilities like grep or awk but i want to do that with sed!
nymus7
  #2 (permalink)  
Old 04-14-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
sed -n "/jobid 2345/s/.*\[\(.*\)\].*/\1/p"
  #3 (permalink)  
Old 04-14-2005
nymus7 nymus7 is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 47
Hi
It's working...
Thanks a lot
Sponsored Links
Closed Thread

Bookmarks

Tags
grep or

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0