+ in grep not working
~ $ echo aa | grep "a*"
aa ~ $ echo aa | grep "a+" ~ $ echo aa | grep "[a-z]" aa ~ $ echo aa | grep "[a-z][a-z]" aa ~ $ echo aa | grep "[a-z]+" can some one help why the + is not working . |
From 'info grep'
Quote:
Code:
bash-4.2$ echo aa | grep "a+" |
Thanks a lot .
I tried them echo aa | grep -E "a+" works but echo aa | grep "a\+" is still not working my bash version is GNU bash, version 3.2.0(1) not sure how to get the version of grep |
see man page of grep, in general grep --version should work
|
From the man page:
Quote:
Code:
jlinkels@donald-pc:/tmp$ grep -V Code:
jlinkels@donald-pc:/tmp$ echo aa | grep "a+" Escaping the + symbol is nonsense, it is part are the regular expression, not to be taken as literal character. |
Quote:
Code:
echo aa | grep 'a\+' |
Thanks all,
grep -V grep (GNU grep) 2.14 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This seems to be my grep version . echo aa | grep 'a\+' echo aa | grep "a\\+" echo aa | grep a\\+ All three are working fine . Also i did not understand the part about shell removing my back slash . Please help me in understanding it . Where can i find information on how shell would react to '\' at different places . |
The manpage for bash has a section on quoting. Understanding of paragraphs 5 through 7 is essential for doing much with the shell command line.
|
Thanks everyone , it really helped a lot
|
There is a difference between grep and egrep concerning escaping meta-characters.
Quote:
jlinkels |
All times are GMT -5. The time now is 03:58 AM. |