shell - Strange regex behavior with grep -
grep '[:digit:]{1,}-{1,}' *.txt| wc -l
this command outputs: 0
grep '1-' *.txt| wc -l
however, command outputs: 10598
both commands being run same directory. first command should have returned greater or equal output of second command. can shed insight going on here?
echo 1 | grep '[:digit:]' #nothing....
grep
uses different syntax, need [[:digit:]]
or [0-9]
.
the {1,}
syntax not supported basic grep, can use other modes, extended 1 -e
... note: 1 use +
matching 1 or more characters....
general note: test regexes in small parts see each part thought does. once expression gets complicated, it's hard tell went wrong.
Comments
Post a Comment