The UNIX and Linux Forums  

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
how to concatenate values of two variables with an underscore(_) in between badrimohanty Shell Programming and Scripting 8 06-16-2009 12:24 PM
allow only alphnumeric entry and an underscore vickylife Shell Programming and Scripting 2 06-09-2009 10:09 AM
usage of underscore in awk ahmedwaseem2000 Shell Programming and Scripting 6 12-08-2008 07:18 AM
problem with underscore in variable name pinkie UNIX for Dummies Questions & Answers 3 04-07-2008 09:27 AM
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 03:37 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2009
danmauer danmauer is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 42
egrep string except when preceded by underscore

having trouble with this seemingly simple taks..

Test data:

Quote:
${DB2HOME}/load_${Gmdsschema}.crnt_rgn_trunc_${SYS_FILE_DATE}
replace into ${Gmdsschema}.crnt_rgn
${Gmdsschema}.crnt_rgn
${DB2HOME}/load_${Gmdsschema}.crnt ${Gmdsschema}.base_rgn
we want to keep lines 2,3 & 4

-- want to exclude when ${.*schema} is preceded with an underscore; Valid {.*schema} should always be preceded spaces or be found at the beginning of a line.



Code:
 
egrep "[^_][$]{.*schema}\."
I would like to thank whomever looks at this in advance for your time .
  #2 (permalink)  
Old 09-30-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 707
Code:
egrep '^\${[^}]*schema}|[^_]\${[^}]*schema}'

Last edited by Scrutinizer; 10-01-2009 at 06:57 PM..
  #3 (permalink)  
Old 10-01-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 707
or :
Code:
egrep '(^|[^_])\${[^}]*schema}'
  #4 (permalink)  
Old 10-01-2009
edidataguy edidataguy is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 173
Won't this not work for you?
Code:
fgrep '_${' file
  #5 (permalink)  
Old 10-02-2009
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 707
Quote:
Originally Posted by edidataguy View Post
Won't this not work for you?
Code:
fgrep '_${' file
Hi editaguy, the OP was trying to match patterns without the preceding underscore. They should also be matched when at the beginning of a line.
  #6 (permalink)  
Old 10-03-2009
edidataguy edidataguy is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 173
Quote:
Originally Posted by Scrutinizer View Post
Hi editaguy, the OP was trying to match patterns without the preceding underscore. They should also be matched when at the beginning of a line.
Oooops....sorry some how I missed it.
Then will this work?
Code:
sed '/_\${.*schema}/ {/ \${.*schema}/!d;}' file
Reply

Bookmarks

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 02:18 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