What is the output difference between these commands?
ps -ef | grep \[t\]tyS1
and
ps -ef | grep ttyS1
Expected results is that previous will grep for [t]tyS1
but is not actually happening.
What is the output difference between these commands?
ps -ef | grep \[t\]tyS1
and
ps -ef | grep ttyS1
Expected results is that previous will grep for [t]tyS1
but is not actually happening.
Both commands looks for the same word: ttyS1, because the 'optional letters' that you put enclosed squared braquets contains only 't'. If you want to search for the string: [t]tyS1, you should enclose your regular expression between quotes (" or ') to avoid shell substitutions, but I'm not sure if it is your purpose.
ps -ef | grep "\[t\]tyS1"
In the case that you want to search for ttyS1 OR ptyS1 the command would be:
ps -ef | grep '[pt]ty'
Hope this helps you.