Find the answer to your Linux question:
Results 1 to 3 of 3
Hi Everyone I hope you will help me with my little problem, I am not very experienced with Linux. I have got a fille which contains something like : .\home\user\readme.txt ...
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    2

    sed from "\" to "/"

    Hi Everyone

    I hope you will help me with my little problem, I am not very experienced with Linux.

    I have got a fille which contains something like :

    .\home\user\readme.txt
    .\home\user\results.txt
    .\home\user\abc.txt

    filenames in Windows notations. I need to convert it into Linux notation i.e. replace "\" symbol with "/" symbol. Sed is the first thing which comes into my head. BUT the problem is SED uses "/" symbol to separate parameters. I tried to use another separator (":") but still doesn't work.
    Anyone can suggest a method/tool to substitute "\" with "/" in a file/stream ?

    Thanks in advance for any help.
    Regards
    ksv689

  2. #2
    Just Joined! cheapscotchron's Avatar
    Join Date
    Dec 2008
    Location
    swamps of jersey
    Posts
    68
    You need to "escape" the \
    However, if you try to do this from the command line, the shell with try to interpret the escapes.

    Create a file (sedcmd) with this line in it:
    s/\//\\/g

    Then from the command line...
    sed -f sedcmd < inputfile > outputfile

  3. #3
    Just Joined!
    Join Date
    May 2009
    Posts
    2
    Hi cheapscotchron

    Tahnks a lot, worked well for me.
    Actually running just

    sed 's/\\/\//g' > outfile

    was good enough.

Posting Permissions

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