LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack 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: 58
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: 55
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: 349

Rep: Reputation: 30
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 08:19 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration