On Friday, September 27, 2002, at 01:57 am, Adriano Allora wrote:
> I need to convert some dos files in unix files, are there commands I
> can use (like recode)?
I'm assuming you mean text files and you need to convert line endings.
You'll need to edit the @files array putting in the full paths to the
files you want to update, saving them to disk I'll leave up to you ;-)
==cut below this text=
#!/usr/bin/perl -w
use strict;
# Unix systems (Unix, Linux, OSX) '\n' = ASCII '\012' ('\f' line feed).
# MacOS9 and earlier '\n' = ASCII '\015' ('\r'
carriage return).
# MS-DOS,Windows systems '\n' = ASCII '\012\015' ('\f\r' line
feed + carriage return).
my($temp,@files);
@files=(ADD YOUR FILE LIST HERE);
for $temp(@files){
open (IN,$temp);
while (<IN>) {
tr/\015/\012/s ; # change Dos/Win/Mac line endings to Unix/OSX
ones }
}
==cut above this text=
HTH
Robin