doubt regardin regex in grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting doubt regardin regex in grep
# 1  
Old 09-11-2005
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 ???
# 2  
Old 09-11-2005
Well, I dont know what exactly [^C] will do, but just ^C matches all lines that start with an upper case 'C'.
# 3  
Old 09-11-2005
Looks like a homework assignment.
# 4  
Old 09-02-2008
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
# 5  
Old 09-02-2008
Quote:
Originally Posted by bwreed
[^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'.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep regex

Hi everyone, I'm looking for a grep command to match the following pattern from a file: <EGS>10234567<EGS> I used this following command to do this: grep -E '^<EGS>{8}<EGS>' test.txt In output I got: <EGS>10234567<EGS> Till now it work, but if I add something at the end of the line... (2 Replies)
Discussion started by: Arnaudh78
2 Replies

2. UNIX for Beginners Questions & Answers

Grep in regex

Hello guys, Here i am writing a script in bash to check for a valid URL from a file using regex This is my input file http://www.yahoo.commmmmm http://www.google.com https://www.gooogle.co www.test6.co.in www.gmail.com www.google.co htt://www.money.com http://eeeess.google.com... (2 Replies)
Discussion started by: Meeran Rizvi
2 Replies

3. Shell Programming and Scripting

Grep command doubt

Hi all, I need to find the line by using grep command with the two occurence of word in the same line. I tried the below example it prints the word choice. cat nohup.out Dictionary utl is completed. file is completed. Dictionary file is completed. grep 'Dictionary\|file'... (0 Replies)
Discussion started by: arun888
0 Replies

4. Shell Programming and Scripting

Doubt with regex to replace square bracket

there is a word "welcome" output should be "welcome\ i am using regsub to add backslash "\" in place where ever i find square brackets (open or close).. But i am not getting it... pls help out.. set a {welcome} set d (5 Replies)
Discussion started by: Syed Imran
5 Replies

5. Shell Programming and Scripting

Doubt on RegEx

Friends, I have a silly doubt: Assume that I have a line like this Heading: Value1; SomeText1 (a, b, c), Value 2; SomeText2 (d, e, f) I wanted to remove all semicolon and remove everything in brackets (including brackets). I managed to do this using this code if... (1 Reply)
Discussion started by: dahlia84
1 Replies

6. Shell Programming and Scripting

doubt in grep

Hi I need to grep a particular world like and redirect into a temporary file .But while iam grepping some unwanted data are aslo coming like .ex In a FILE all these TABLENAMES are present . module_table1,module_table2, module_table3,module_table5, module_table1_temp , module_table2_temp... (9 Replies)
Discussion started by: mani_isha
9 Replies

7. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

8. Shell Programming and Scripting

doubt in grep command

Hello i am new shell scripting. I have a file like this, $ cat myfile ;/abc/abc.cpp@@/main/1;xyz ;/abc/abc.cpp@@/main/2;usr2 ;/abc/abc.cpp@@/main/1;abc ;/abc/abc.cpp@@/main/2;usr2 ;/abc/abc.cpp@@/main/1;usr1 when i grep the file. $ grep "abc" myfile... (8 Replies)
Discussion started by: tsaravanan
8 Replies

9. UNIX for Dummies Questions & Answers

Help with grep and regex

Hi all, I'm a beginner with linux, regex, grep, etc I am trying to get data out of a file that has about 13,000 lines in this format name - location I want to grep all the names out to one file and the locations to another so I can put them into a spreadsheet. Some have hyphenated... (14 Replies)
Discussion started by: raichlea
14 Replies

10. UNIX for Dummies Questions & Answers

Grep doubt

Hi, I have one txt file as bellow: Inspector logging xxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx Inspector logging xxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxx Inspector loggingxxxxxxxxxxxxxxx Inspector logging xxxxx xxxxxxxxxxxxxxxxxxxxxxxx I want... (1 Reply)
Discussion started by: redlotus72
1 Replies
Login or Register to Ask a Question