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 bloghttp://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 Mathematica InputForm string of a Chinese character:

    $ grep -x --color=always "\\:0251" temp.txt :0251

Posted Tue May 16 23:59:39 2017

Older posts:

Hello world!
Posted Tue May 16 23:59:39 2017
Information Metabolism of Society
Posted Tue May 16 23:59:39 2017
Installing CheckStyle plugin for Eclipse
Posted Tue May 16 23:59:39 2017
Log statistics for revision control systems
Posted Tue May 16 23:59:39 2017
NHK 纪录片《圆的战争》
Posted Tue May 16 23:59:39 2017
Steve Jobs Quotes
Posted Tue May 16 23:59:39 2017
Taking online courses
Posted Tue May 16 23:59:39 2017
Tweaking Mathematica command-line interface
Posted Tue May 16 23:59:39 2017
Back up MediaWiki
Posted Tue May 16 23:59:39 2017
grep and backslash
Posted Tue May 16 23:59:39 2017
Installing and configuring Java on Mac
Posted Tue May 16 23:59:39 2017
n-squared time complexity is really slow
Posted Tue May 16 23:59:39 2017
Note on setting up Java projects using Gradle
Posted Tue May 16 23:59:39 2017
Notes on running forms
Posted Tue May 16 23:59:39 2017
principle of a single big jump
Posted Tue May 16 23:59:39 2017
Relearning p-value
Posted Tue May 16 23:59:39 2017
Removing newline characters
Posted Tue May 16 23:59:39 2017
Save Kuvva wallpaper images automatically
Posted Tue May 16 23:59:39 2017
How to switch font and theme in Emacs
Posted Tue May 16 23:59:39 2017
Random notes about Unicode
Posted Tue May 16 23:59:39 2017
wolfram-related twitter accounts
Posted Tue May 16 23:59:39 2017
叠字
Posted Tue May 16 23:59:39 2017
美国国债扫盲资料
Posted Tue May 16 23:59:39 2017
钓鱼岛及其部分附属岛屿图
Posted Tue May 16 23:59:39 2017
pi day.draft
Posted Tue May 16 21:14:19 2017
Compute sample variance of data stream
Posted Tue Oct 6 19:39:59 2015
Leveled logging in Bash
Posted Thu Mar 19 07:49:38 2015
Wolfram-related Twitter accounts and the alike
Posted Sat Mar 7 02:37:38 2015
Permission of .ssh files
Posted Thu Feb 26 00:32:53 2015
blog comments powered by Disqus