[X-Unix] Why didn't Apple change the line bre ak ?

James Bucanek subscriber at gloaming.com
Tue Sep 21 07:02:06 PDT 2004


Craig wrote on Tuesday, September 21, 2004:

>This may be unrelated, but why is it that on OS X, if you redirect the 
>output of
>ls or some other commands into a text file then open the file with a 
>text editor,
>you see something like this:
>
>[01;34malias sketchbook examples[0m
>[0mls.txt[0m
>[01;34mnew pix[0m
>[0moreilly.com -- Online Catalog- PDF Hacks.webloc[0m
>[0mwiretap.sit[0m
>[0mzip code article-LVRJ.html[0m
>[0mzip code map-LVRJ.gif[0m
>[m
>
>which should, & if you cat the file does, look like this:
>
>alias sketchbook examples
>ls.txt
>new pix
>oreilly.com -- Online Catalog- PDF Hacks.webloc
>wiretap.sit
>zip code article-LVRJ.html
>zip code map-LVRJ.gif
>
>thanks,
>Craig

Because, as Eugene pointed out, your text editor sucks.  Get a decent one like BBEdit or TextWrangler.  Even Apple's bundled TextEdit will handle most line endings correctly.

Output from most UNIX command line tools will use UNIX line endings (LF).  The cat tool just outputs the contents of the input, verbatim.  Byte for byte.  No changes.  If the source file had DOS line endings, the output will have DOS line endings.

So you're obviously using a text editor that can't compensate for the different line ending standards, and the file that you are cat'ing is in a format your editor is comfortable with.  Thus, it doesn't understand the output of ls and the output of cat was just a copy of a file it does understand.

-- 
James Bucanek <mailto:privatereply at gloaming.com>



More information about the X-Unix mailing list