linux - grep: Invalid regular expression -


i have text file looks this:

haha1,haha2,haha3,haha4 test1,test2,test3,test4,[offline],test5 letter1,letter2,letter3,letter4 output1,output2,[offline],output3,output4 check1,[core],check2 num1,num2,num3,num4 

i need exclude lines have "[ ]" , output them file without lines have "[ ]".

i'm using command:

grep ",[" loaded.txt | wc -l > newloaded.txt 

but it's giving me error:

grep: invalid regular expression

use grep -f treat search pattern fixed string. replace wc -l grep -c.

grep -cf ",[" loaded.txt > newloaded.txt 

if you're curious, [ special character. if don't use -f you'll need escape backslash.

grep -c ",\[" loaded.txt > newloaded.txt 

by way, i'm not sure why you're using wc -l anyways...? problem description, sounds grep -v might more appropriate. -v inverts grep's normal output, printing lines don't match.

grep -vf ",[" loaded.txt > newloaded.txt 

Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

java - Incorrect order of records in M-M relationship in hibernate -