Hi,
the original question was:
> some unix files crashes PC-applications because each line ends
> with \n (newline), but should end with \r \n (carriage return
> and newline). Has anybody a script (sed ?), that inserts \r
> before \n ?
Thanks for all the prompt responses. Here are the answers.
-------------------------------------------------------------
Use ftp (asci-transfer-mode)
-------------------------------------------------------------
this works fine!!!
-------------------------------------------------------------
Use sed
-------------------------------------------------------------
#/bin/csh -f
sed -e 's/$/^M/' $1 > $2
...............................................................
Being that as it may:
sed 's/$/^M/' file > file.Microsoft
where you type the ^M as a control-V and a control-M will do the
trick, just as
sed 's/^M$//' file.Microsoft > file
will reverse the process.
-------------------------------------------------------------
Use other Unix-tools
-------------------------------------------------------------
awk '{printf("%s\r\n", $0)}' filename.nl > filename.crnl
cat file | awk '{printf $0 "\n\r"}'
tr "\012" "\015" < infile > outfile <-- this does not work !!
-------------------------------------------------------------
Use c-programs
-------------------------------------------------------------
-------------------------------------------------------------
Use pearl (we dont have pearl)
-------------------------------------------------------------
perl -pi.bak -e 's/\n/\r\n/' file
#! /usr/bin/perl -wpi.bak
s/$/\r/ ;
#!/usr/local/bin/perl -pi~
s/\n/\r\n/o;
#!/usr/local/bin/perl -pi~
s/\r//o;
#!/usr/local/bin/perl
# file name is c.pl
# this has not been tested Werner!
while (<>)
{
s/$/
/;
print $_;
}
-------------------------------------------------------------
Misc.
-------------------------------------------------------------
http://bul.eecs.umich.edu/~crowej/u2d.html (very nice!)
Mit freundlichen Grüßen
Werner Rost
------------------------------------------------------
Werner Rost, Mannesmann-Boge GmbH
Abt: KIR
Tel: 0228/3825-420
Fax: 0228/3825-398
Email: werner.rost_at_boge.mannesmann.de
Friesdorfer Str. 175, 53175 Bonn - Bad Godesberg
------------------------------------------------------
- application/octet-stream attachment: dos2ux.c
- application/octet-stream attachment: u2dosx.c
Received on Wed Dec 08 1999 - 07:48:42 NZDT