Mailinglist Archive: opensuse (3280 mails)

< Previous Next >
Re: [opensuse] Need help doing a batch conversation lf - cr/lf
  • From: "Otto Rodusek (AP-SGP)" <otto@xxxxxxxxxxxxxx>
  • Date: Fri, 07 Dec 2007 08:56:36 +0800
  • Message-id: <47589A44.2000003@xxxxxxxxxxxxxx>
Randal Jarrett wrote:
I'm looking for either a utility or simple script (bash/perl) to convert text files from linux (lf) format to dos (cr/lf).

I need to move over 10k files and maintain the directory
structure while doing it. A lot of the files and some of the
directories have spaces in the name. I can process them on my system
and then move them to the win server. I also have to maintain the
original files & structure.

Any and all assistance is appreciated.

use a script as follows:

#Description: Add CR to text files'
for f
do
mv $f ${f}.orig && awk '{ printf "%s\r\n", $0 }' ${f}.orig >$f
done

reverse:

# Description: Remove CR and control-Z from text files'

for f
do
mv $f ${f}.orig && tr -d '\015\032' <${f}.orig >$f
done


rgds. Otto Rodusek
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
References