in reply to Re: Re: Another dos to unix question
in thread Another dos to unix question

update: sorry -- I missed this part in your OP: "how i can convert a list of files, stored in a 'list file'" I have added a bit to the script to account for this. As modified, you can pipe a list of file names to the script on stdin (e.g. "ls | script.pl") or store the list(s) in some named file(s) and give the list file name(s) to the script as ARGV (e.g. "script.pl list [list2 ...]" /update.

Well then, you could create a perl script file as follows:

#!/usr/bin/perl # in-place dos-to-unix conversion (remove ^M's): my @file_list = <>; # update: adding these two lines to chomp @file_list; # read a list of file names for my $file ( @file_list ) { # not "@ARGV" open( I, $file ) or die "$file: $!"; open( O, ">$file.unx" ) or die "$file.unx: $!"; while (<I>) { s/\cM*//g; print O; } close I; close O; rename "$file.unx", $file or die "renaming $file.unx to $file: $!" +; }

Note that this differs slightly from the code in your original post: your strange and less efficient approach would cause each "CRLF" sequence in a dos file to be converted to "LFLF", which means your output files would have twice as many "lines" as the originals, and half of those output lines would be empty. The version here simply removes the "CR". (Or maybe it was your intention that dos files should show up in unix as "double-spaced"?)