3 ms·
regex background: [abc] matches any of 'a', 'b', or 'c'. [m] matches only 'm'. It works because the text to match is no longer included in the command line in
by sjs 17y ago
regex background: [abc] matches any of 'a', 'b', or 'c'. [m] matches only 'm'.
It works because the text to match is no longer included in the command line invoked to do the matching. Whether or not 'grep [m]ysqld' appears in the list produced by ps is irrelevant, as [m]ysqld does not match "m]ysqld". i.e. the 'm' matches, but then the match fails when it hits ']'.
tl;dr It's just a short way of matching "mysqld" without the matching pattern itself being "mysqld".