in reply to Re: Re: Another dos to unix question
in thread Another dos to unix question
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"?)
|
|---|