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

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -