Find the answer to your Linux question:
Results 1 to 5 of 5
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Problem with Grep

    I have searched this site and did not find the specific answer to my issue, so sorry if it is out there and I missed.

    I am trying to use grep to find string of text in my source code that ends with a "\". My programs will run on either a Windows system or UNIX/Linux but when I create work files I have to change the "\" to "/" when running on UNIX/Linux. But I have a program that is not changing the "\" so it will create a file like the following;
    I have issued the following command and it returns an error message;

    grep -rl "RWWRK\\" *

    grep: Trailing backslash

    I have approximately 1200 source programs in 20 different directrories to search.

    Can someone please point me in the right direction so I can find the problem in my code?

    Thank you very much for your time!!

  2. #2
    Linux User
    Join Date
    Jan 2007
    did you try with single quotes?

    grep -rl 'RWWRK\\' *
    the sun is new every day (heraclitus)

  3. #3
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    Wrap your search in single quotes ' and ' instead of double quotes, and it will work.

  4. $spacer_open
  5. #4


    Quote Originally Posted by mizzle View Post
    Wrap your search in single quotes ' and ' instead of double quotes, and it will work.
    Mizzle and tpl, you are awesome! That did the trick! Thanks!!!

  6. #5
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Other than that, please consider remediating your programms.
    If I understand your post correctly, then there are hardcoded paths in your code. Use parameters or config files instead.
    And the second point is: Your code should be able to deal with windows and linux style path separators, if the programs are intended to run on both platforms.
    Afaik nearly all relevant languages will have classes or abstraction layers for that purpose already.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts