LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-20-2011, 12:07 PM   #1
nardo
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, 12:42 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Hello,

I have found a thread similar to this, locate here: http://www.linuxquestions.org/questi...kslash-136312/

Hope that helps man!

Cheers,

Josh
 
Old 05-20-2011, 01:30 PM   #3
spazticclown
Member
 
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.

Try
Code:
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, 01:48 PM   #4
MTK358
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.
 
  


Reply


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 04:14 PM
scripting to convert DOS '\' to UNIX style slashes poonamkhirolia Linux - Newbie 2 12-17-2010 09:35 AM
script to convert dos to unix format kapilcool Linux - Software 3 06-15-2006 11:50 AM
Command to convert dos file to a unix format sathish80 Linux - Newbie 1 03-22-2006 11:32 PM
Getting a DOS-style sorted directory listing KimVette Linux - General 2 01-29-2006 11:22 AM


All times are GMT -5. The time now is 03:56 AM.

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