Re: [OT] UNIX heads; can I do this?
Re: [OT] UNIX heads; can I do this?
- Subject: Re: [OT] UNIX heads; can I do this?
- From: John Hawkinson <email@hidden>
- Date: Wed, 13 Jun 2007 16:23:03 -0400
Bill Briggs <email@hidden> wrote on Wed, 13 Jun 2007
at 16:54:31 -0300 in <p0623091cc295fa89b368@[131.202.97.88]>:
> I want to take a text file with Mac (cr) line endings and change to
> UNIX (lf) line endings (eventually I'm piping it to awk, which needs
> the lf or it sees it all as one line).
Pipe through
tr \\015 \\012
Note that you must pipe through it, i.e.
tr \\015 \\012 < t.txt > b.txt
you may *not* give a commandline argument to tr:
tr \\015 \\012 t.txt > b.txt
it will fail.
> sed -e 's/^M//g' t.txt | cat > b.txt
p.s.: this construction wastes the cat...any instance of "| cat >" can
always be replaced simply by ">" and save yourself a step.
> Then again, maybe it's not possible to do that with sed, but I can't
> see why not.
Sed doesn't like to work with linebreaks, it likes to work the things
between them. Trying to do it leads to more grief. Just use tr
(or tr and sed together if you also need to perform other
operations. i.e. tr \\015 \\012 < t.txt | sed s/nokia/iPhone/g > b.txt).
--jhawk
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden