[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LF to CR Conversion
In article <35hdq1$hp7@newsserv.cs.sunysb.edu>,
Jason Simmons <jsimmons@cs.sunysb.edu> wrote:
>In article <35h9pe$jc8@panix2.panix.com> moxie@panix.com (Mark Mentovai) writes:
>>I want to know of a program for Unix that will change all Linefeeds
>>to Carriage Returns in a specified file,
>
>tr can do this. Pipe your file through "tr '\015' '\012'".
>
Ummmmm. And when you're wondering why that didn't work, try:
tr '\012' '\015'
Sorry Jason!
BTW, here's the script I use for this purpose:
--- CUT HERE ---
#! /bin/sh
#
# A script to convert line feeds (chr$ 0x0A) to carriage returns (0x0D)
# in each file named on the invocation line.
#
# Usage: lf2cr <fname1> ... <fname_n>
#
scratch=tempfile$$
for i
do
tr '\012' '\015' < $i > $scratch
mv $scratch $i
done
--- CUT HERE ---
--
Christopher Neufeld....Just a graduate student neufeld@physics.utoronto.ca
"Don't edit reality for | "Genius may have its limitations, but stupidity
the sake of simplicity" | is not thus handicapped." -- Elbert Hubbard