newbie: nice text file
John Hinsley
jhinsley at telinco.co.uk
Thu May 3 03:42:59 UTC 2001
"Richard A. O'Keefe" wrote:
>
> Jeff Shipman <shippy at nmt.edu> wrote:
> Whenever I go to Yellow->More->Save Contents to file
> the file that is produced has a bunch of ^M's
> in it instead of carriage returns.
>
> ^M ***is*** carriage return.
>
> I'm using Squeak under Linux on an i686.
>
> Linux, like other Unix versions, does not use carriage returns.
> Unix uses *linfe feed* characters (ASCII 10) to terminate lines.
>
> Squeak was initially developed on MacOS, which, unlike UNIX,
> uses *carriage return* characters (ASCII 13) to terminate lines.
>
> Squeak source files (and a snippet out of a workspace counts as a
> source file) are supposed to be byte-for-byte identical on all
> supported systems, so the MacOS convention is always used for them.
>
> If Squeak wrote a file Foo using CR and you need a file Bar using LF,
> just do
> tr '\r' '\n' <Foo >Bar
>
> (Check 'man tr' first to ensure that your version of tr understands '\r'
> and '\n'. You might have to use '\015' for CR and '\012' for LF instead.)
Everything Richard writes is correct. I rather like the idea of sorting
it in Squeak, but have yet to try out any of the suggestions.
You might like to use this simple little bash script (called mac2unix
after dos2unix). Just put it in your path (usr/local/bin is as good a
place as any) and make it executable.
It's not the most elegant script, but it works every time.
Cheers
John
--
******************************************************************************
Marx: "Why do Anarchists only drink herbal tea?"
Proudhon: "Because all proper tea is theft."
******************************************************************************
-------------- next part --------------
#mac2unix
#by Isaac Sparrow
#!/bin/bash
echo "This script converts Mac text files to Unix
It WILL overwrite the original file
Please enter the name of the file
you wish to work on"
read file
tr '\r' '\n' < $file > $file.NEW
echo processing $file
mv $file.NEW $file
More information about the Squeak-dev
mailing list
|