Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-20-2011, 01:07 PM   #1
LQ Newbie
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Question convert DOS style

How do I write a script to convert all DOS style backslashes to UNIX style slashes in a list of files /
Old 05-20-2011, 01:42 PM   #2
LQ Guru
Registered: Apr 2005
Posts: 5,818

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004

I have found a thread similar to this, locate here:

Hope that helps man!


Old 05-20-2011, 02:30 PM   #3
Registered: Sep 2010
Distribution: Fedora, Android, CentOS
Posts: 91
Blog Entries: 2

Rep: Reputation: 21
Using the slashes in the sed command can be confusing.

sed 's#\\#\/#g' < filename.txt
In this example instead of using '\' as the separator between sed fields I used '#' to make it more readable, I also escaped the '/' and '\' just to be sure it knew what to do. What it does is substitute '\' with '/' and then 'g' for global in the stream (in this case filename.txt).
Old 05-20-2011, 02:48 PM   #4
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
There's no need to escape the forward-slash is you use a different delimiter.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert few lines of SHELL script to DOS batch vanco2001 Programming 3 04-14-2011 05:14 PM
scripting to convert DOS '\' to UNIX style slashes poonamkhirolia Linux - Newbie 2 12-17-2010 10:35 AM
script to convert dos to unix format kapilcool Linux - Software 3 06-15-2006 12:50 PM
Command to convert dos file to a unix format sathish80 Linux - Newbie 1 03-23-2006 12:32 AM
Getting a DOS-style sorted directory listing KimVette Linux - General 2 01-29-2006 12:22 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration