Matching the [] characters


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Matching the [] characters
# 1  
Old 12-11-2011
Matching the [] characters

I want to check where our programmers are using "delete" instead of "delete[]" in their C++ code:
Code:
grep -r delete *cpp | grep -v []

However, this statement and variations thereof (escaping with backslash (\), single quotes ('), double quotes ("), accolades ({)) always lead to the following message:
Code:
grep: Unmatched [ or [^

What should the correct statement be?
# 2  
Old 12-11-2011
Hi.

Try:

Code:
grep -v '\[]'
grep -Fv []
fgrep -v []

# 3  
Old 12-11-2011
Works great. I will settle for the first option. Thank you.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep with ... matching more than 3 characters

I am trying to understand what the grep command in ubuntu is trying to do here. The contents of my test file is given below harsha@harsha-H67MA-USB3-B3:~/Documents$ cat data abcd efghi jklmno pqr stuv wxyz When I grep for 3 dots (...) without the parenthesis as follows I would expect the... (4 Replies)
Discussion started by: sreeharshasn
4 Replies

2. Programming

Matching first n characters in a line in a file

hi to all, i am writing a simple file program in C which has to take a string of length n as input and match that input string with first n character of the line in file. if it does not match it has to compare with first n characters of next line. i am finding it difficult to know how exactly to... (2 Replies)
Discussion started by: ntrikoti
2 Replies

3. Shell Programming and Scripting

Matching a pattern 250 characters up and down stream

hii all i have a file a which contains some thing like this strand smthg position + yyx 3020 - yyw 10,000 now i have another file (file2) which contains the data starting from 1 to n positions i want to refer first file if + ... (4 Replies)
Discussion started by: anurupa777
4 Replies

4. Homework & Coursework Questions

Matching and Replacing Characters

I need to write an Unix script to report the number of SQL files in my home directory, ending with .sql . The script should, also, be checking whether there is a file with an underscore in its name. If that is the case, the underscore should be converted to a dash (‐); for example... (1 Reply)
Discussion started by: ronoz-4
1 Replies

5. Homework & Coursework Questions

Check 2 variables for matching characters

hi i am writing a hangman script and am having trouble checking the correct letters against the word i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario this must... (1 Reply)
Discussion started by: lsecer
1 Replies

6. Shell Programming and Scripting

Help with checking that 2 variables contain matching characters

hi i am writing a hangman script and am having trouble checking the correct letters against the word i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario eg ... (3 Replies)
Discussion started by: lsecer
3 Replies

7. UNIX for Dummies Questions & Answers

Matching numbers of characters in two lines

Dear all, I'm stuck on a certain problem regarding counting the number of characters in one line and then adjusting the number of characters of another line to this number. This was my original input data: @HWI-ST471_57:1:1:1231:2079/2... (4 Replies)
Discussion started by: DerSeb
4 Replies

8. Shell Programming and Scripting

Matching a pattern between two characters (sed)

Hi there, I have a file with lines like these: 0105:ffff0000:001b:01f4:25:434 0299:ffff0000:0009:01f4:2:319 02d2:ffff0000:000e:01f4:2:507 The above values are split up using ":" characters. I would like capture each value, no matter what length. Take for example the first line... (8 Replies)
Discussion started by: MastaG
8 Replies

9. UNIX for Dummies Questions & Answers

pattern matching w/ unexpected characters

how do i check if the first character is a parenthese in pattern matching? if ] obviously doesnt work. How do I use it to compare so it doesnt try to use it to group. (5 Replies)
Discussion started by: questionasker
5 Replies

10. UNIX for Dummies Questions & Answers

matching characters between strings

please send the logic or program to find the matching characters between two strings for ex string1 :abc string2 :adc no .of matching characters is 2(a,c) (9 Replies)
Discussion started by: akmtcs
9 Replies
Login or Register to Ask a Question