RE: [SLUG] Adding a carriage return after each line in a file.

From: Brett Simpson (Simpsonb@hillsboroughcounty.org)
Date: Tue Jan 08 2002 - 16:05:01 EST


Andrew had suggested using this perl script to get the carriage returns in place and it worked.

#!/usr/bin/perl
if ($ARGV[1] eq "")
{
  print "Usage: scriptname filein fileout\n";
}

@in=`cat $ARGV[0]`;
open (out,">$ARGV[1]");
foreach $line(@in)
{
  chomp $line;
  print out $line."\n\n";
}
close (out);

>>> bfoxworth@fortresstech.com 01/08/02 03:14PM >>>
Can't you pipe it through sed and do a global search for all
0x0d and replace with 0x0d0x0a (whatever the octal values are)
The newline is a CR (0d) and for DOS mode you have to add a
LF (0a) after each CR. This may be do-able with tr also.
The script could ' cat oldfile | sed [arg] > newfile' However I
never tried doing it.

> Hi,
>
> Is it possible to add a carriage return after each line in a file? I know
> in vi you can use CTRL-V to add a <CR> but I'm not sure how to automate it
> to do it after each line. Each line is 856 bytes in size and corresponds
> to a record. Also is their a way to do this from a script so I can
> automate through cron every day. Thanks.
>
> Brett



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 18:25:09 EDT