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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with grep and regex raichlea UNIX for Dummies Questions & Answers 14 04-16-2008 08:25 AM
grep with Regex help! mvalonso UNIX for Dummies Questions & Answers 3 06-01-2007 12:36 PM
Problem with grep Regex Error lweegp Shell Programming and Scripting 6 11-16-2006 01:04 AM
grep regex problem iceman Shell Programming and Scripting 2 02-06-2005 09:44 AM
use of regex on grep solea UNIX for Dummies Questions & Answers 0 09-30-2004 08:13 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-11-2005
Registered User
 

Join Date: Sep 2005
Posts: 3
doubt regardin regex in grep

shudnt this command :
grep [^C] test

give all the lines which do not hv 'C'. ^ wrks as negating character inside square brackets right ???

bt in my case grep is printin all the line in the file

also wht does
grep c+ test & grep c? test
shud do ???
Reply With Quote
Forum Sponsor
  #2  
Old 09-11-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Well, I dont know what exactly [^C] will do, but just ^C matches all lines that start with an upper case 'C'.
Reply With Quote
  #3  
Old 09-11-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Looks like a homework assignment.
Reply With Quote
  #4  
Old 09-02-2008
Registered User
 

Join Date: Mar 2002
Location: Saint Paul, MN
Posts: 6
I know this is an old question, but here's an old answer to match. (It's old because I'm sure the grep command hasn't changed).
[^C] matches any character that's NOT a C.
You might want
$ grep -E "^[^C]*$" test
or more likely, you want
$ grep -vE "[C]" test
Reply With Quote
  #5  
Old 09-02-2008
cfajohnson's Avatar
Registered User
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 791
Quote:
Originally Posted by bwreed View Post
[^C] matches any character that's NOT a C.

And, since it is not quoted, it will expand to all the single-letter filenames in the current directory (other than C itself).

As a result, the search pattern will be the first matching file, and any others matching files will be searched along with 'test'.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0