linux - Why does grep return different results when regex is used? -


> ps -ef | grep cron  root      1052     1  0 04:35 ?        00:00:00 cron test   4071  4053  0 10:15 pts/0    00:00:00 grep --color=auto cron  > ps -ef | grep cr[o]n  root      1052     1  0 04:35 ?        00:00:00 cron 

why these 2 commands return different results when search term equivalent?

because in second case processes running (altough second cannot see after grep filter applied):

root      1052     1  0 04:35 ?        00:00:00 cron test   4071  4053  0 10:15 pts/0    00:00:00 grep --color=auto cr[o]n 

and cr[o]n not matched cr[o]n [o] specifies list of characters o, while real string contains [ , ] around o.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -