LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-15-2006, 09:14 AM   #1
kapilcool
Member
 
Registered: Dec 2005
Posts: 32

Rep: Reputation: 15
script to convert dos to unix format


Hi,
Can anyone help me with writing a script to convert all DOS style backslashes to UNIX style slashes in a list of files?

Thanks
Kapil
 
Old 06-15-2006, 09:44 AM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
does the command :
Code:
dos2unix filenamehere
work for you ??
 
Old 06-15-2006, 10:14 AM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 60
If you need to make a script instead of using the dos2unix program, this example might get you started ...
Code:
#!/bin/bash

mkdir /home/tmp 2> /dev/null
cd /home/images

for i in *.txt ; do
cat "$i" | tr -d '\015' > "/home/tmp/$i"
done
mv -v /home/tmp/*.txt /home/images
 
Old 06-15-2006, 12:50 PM   #4
madluther
Member
 
Registered: Aug 2004
Distribution: LFS
Posts: 350

Rep: Reputation: 31
The following will replace back slashes with forward slashes within a file

Code:
cat dos.txt | tr  '\\' / > unix.txt
Mad.
 
  


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 DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 12:42 PM
A script to convert maildir to mailbox format i_s Linux - General 7 12-14-2009 04:20 PM
Command to convert dos file to a unix format sathish80 Linux - Newbie 1 03-23-2006 12:32 AM
Help with script to convert different Video file types to wmv format for streaming farmerjoe Programming 1 11-17-2005 02:12 PM
newline problem between DOS and Unix format cjs_pro Programming 7 03-11-2005 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:26 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