LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 08: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, 08: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, 09:14 AM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
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, 11:50 AM   #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



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

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

All times are GMT -5. The time now is 11:58 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
Open Source Consulting | Domain Registration