SUMMARY: How to search for a string containing \

From: Owens, Blaine C - Eastman <bowens_at_eastman.com>
Date: Thu Jul 31 2003 - 13:20:00 EDT
Many correct answers to this one, obviously this is a FAQ. I'm attaching
one of the best responses, this one from Joe Rice. Thanks to all.

-----Original Message-----
From: Joe Rice [mailto:jrice@abnamroinc.com]
Sent: Thursday, July 31, 2003 12:54 PM
To: Owens, Blaine C - Eastman
Subject: Re: How to search for a string containing \


# echo '\' > test.txt
# grep '\\' test.txt
\
#

the key here is to escape the \ with another \
Also, use '\\' (single quote) instead of "\\" (double quote)
because of the way the shell will interpret the \ in a double quote.

# awk '/\\/ { print $0 }' test.txt
/
#

# perl -ne 'if ( /\\/ ) { print }' test.txt
/

hope this helps.

joe rice

>>> "Owens, Blaine C - Eastman" <bowens@eastman.com> 07/31/03 09:03AM
>>>
How do you grep for a string in file which literally contains the \
character? Thanks.

Blaine Owens
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Thu Jul 31 13:23:51 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:17 EST