I need to select the rows of a file that contains the characters |
or \
diff -y ontem.csv hoje.csv | grep -e "|" -e "\"
How to tell pro grep to return the rows it contains either a |
or a \
?
I need to select the rows of a file that contains the characters |
or \
diff -y ontem.csv hoje.csv | grep -e "|" -e "\"
How to tell pro grep to return the rows it contains either a |
or a \
?
You can use the []
delimiters, which get all the characters inside them (the \
must be escaped, so it gets \
):
grep -e "[\|]"
See examples of this regex here .
As reported in the comments, grep
also works without the -e
option and does not need to escape the bar:
grep "[\|]"
You can use the regular expression [\|]
, see:
grep:
$ diff -y ontem.csv hoje.csv | grep '[\|]'
egrep:
$ diff -y ontem.csv hoje.csv | egrep '[\|]'
awk:
$ diff -y ontem.csv hoje.csv | awk '/[\|]/{print}'
perl:
$ diff -y ontem.csv hoje.csv | perl -nle 'print if m{[\|]}'
sed:
$ diff -y novas.csv entrada.txt | sed -n '/[\|]/p'