SUMMARY: How to search for a string containing \

From: Owens, Blaine C - Eastman (bowens_at_eastman.com)
Date: 07/31/03

  • Next message: rmck: "Update to Ultra 5 connect to two networks"
    Date: Thu, 31 Jul 2003 13:20:00 -0400
    To: <sunmanagers@sunmanagers.org>
    
    

    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


  • Next message: rmck: "Update to Ultra 5 connect to two networks"