Some casual bibliophile, dataphile, sinophile, logophile, pluviophile, cartophile, mycophile, tea connoisseur, urban farmer, and amateur naturalist topics ...
RSS:
English blog:http://meng6.net/pages/blog/index.rss
,
feedburner,
subscribe by email
Chinese blog:http://meng6.net/pages/zh/blog/index.rss
Using or matching backslash character ('\') correctly with
grep
or similar tools such as ack
takes
some investigation. Here is a note on what I found.
GNU grep
I created a text file temp.txt
with
\
\\
\\\
\:0251
What I get from trying to match each line with grep
(GNU bash 3.2.48) from Bash command line:
-
Use
"\\\\"
to match\
$ grep -x --color=always "\\" temp.txt \
-
So to match
\\
,\\\\\\\\
is needed:$ grep -x --color=always "\\\\" temp.txt \
-
To Match
\:0251
which is the MathematicaInputForm
string of a Chinese character:$ grep -x --color=always "\\:0251" temp.txt :0251
Older posts:
Posted Tue May 16 23:59:39 2017
Posted Tue May 16 23:59:39 2017