The classic one liner here is:
perl -pi -e 's/\r\n/\n/' file.raw
which is essentially short for
#!/usr/bin/perl
use strict;
use warnings;
use File::Temp qw/ tempfile /;
use File::Copy;
my ($out, $filename) = tempfile("$ARGV[0]_XXXX", UNLINK => 0);
open my $in, '<', $ARGV[0] or die "Open failed: $!";
while (defined(my $line = <$in>)) {
$line =~ s/\r\n/\n/;
print $out $line;
}
close $in;
close $out;
move($filename, $ARGV[0]);
See -e, -p and -i in perlrun, and review perlretut for details on regular expressions.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|