I found dos2unix at "http://hany.sk/~hany/_data/hd2u/" and it was easy
to install, but it is one more thing you have to remember to do if you
do a fresh install.
The following is more or less equivalent to dos2unix (converting DOS
files, which use CRLF as line terminators):
perl -pi -e 's/\r//g' file.txt
To convert a Mac-format file (which IIRC some OS X editors still use),
which uses only CR as a line terminator:
perl -pi -e 's/\r/\n/g' file.txt
If you're using as a pipe, you can (probably) omit -i (untested). (I
don't think it hurts, though, also untested.)
--keith
--
kkeller...@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
>I know what you are thinking. Why in the earth would a true Slacker
>that stays away from DOS and MS products need with a "dos2unix" command.
>Well it turns out it is very handy when writing bash scripts. If you
>have a script that you run with cron that captures stdout results to a
>file to mail using "cat" and "mailx", you sometime have a carriage
>return embedded in it that results in email with the dreaded
>"Application/OCTET-STREAM:" attachment that Pine cannot easily read. If
>you instead run any resulting files from your script through dos2unix
>before mailing them, it cleans the file up and it shows the text in the
>body of the mail where it can be easily read.
Hmm, I been running mixed windows and linux on localnet since '97,
hardly ever face this issue.
>
>I found dos2unix at "http://hany.sk/~hany/_data/hd2u/" and it was easy
>to install, but it is one more thing you have to remember to do if you
>do a fresh install.
sed, tr, gawk, perl (as another mentioned) -- lots of ways to defeat
silly-dos crlf nonsense.
Grant.
--
http://bugsplatter.id.au
next tested and works on Slackware 12.2
al@P5Q:~$ perl -MExtUtils::Command -e dos2unix ./dosfil.txt
perl is already on and same with Perl's ExtUtils::Command module
and same with dos2unix which is one of the commands/duties of
that particular perl module.
All of the above os already on.
doc. for that perl module:
http://search.cpan.org/~rkobes/ExtUtils-Command-1.16/lib/ExtUtils/Command.pm
--
mtbr
Is there something that fromdos(1) and/or todos(1) cannot do?
fromdos < infile > outfile
With a bit of creative scripting, you can make your own dos2unix and
unix2dos commands even.
-RW
It was probably about 10 years ago that dos2unix was replaced with
todos/fromdos in slackware. Get with the times, man! ;)
Cheers,
Rob Komar
Du meintest am 06.11.09:
> I found dos2unix at "http://hany.sk/~hany/_data/hd2u/" and it was
> easy to install, but it is one more thing you have to remember to do
> if you do a fresh install.
I found this "dos2unix"
alias dos2unix='recode ibmpc..lat1'
I found it under slackware 11, I found it under slackware 12 and under
slackware 13.
The only problem with "alias": it needs a shell, it seems to be invoked
as part of a profile.
I found this problem in the linux shell of "wsusoffline",
(now it's fixed)
Viele Gruesse
Helmut
"Ubuntu" - an African word, meaning "Slackware is too hard for me".
I have been running Slackware for about as long too, and I have seen the
problem before but it was infrequent and never bothered me enough to do
anything about it - until now. I really wanted to have the results of
a script mailed to me and I use Alpine (Pine) as my mail reader so I
needed a solution.
> >I found dos2unix at "http://hany.sk/~hany/_data/hd2u/" and it was easy
> >to install, but it is one more thing you have to remember to do if you
> >do a fresh install.
>
> sed, tr, gawk, perl (as another mentioned) -- lots of ways to defeat
> silly-dos crlf nonsense.
I thank you, and all the other people who responded as well, with
suggestions. I was unaware of some of them (todos/fromdos for one),
and not clever or imaginative enough to consider others on my own (e.g.,
sed). The dos2unix was the first thing I came across after identifying
the problem, and it solved it very neatly with not much mental strain on
my part in two lines.
dos2unix results.txt
cat results.txt | mail -s Results user
My thanks again to all who responded and I won't expect dos2unix to show
up in /usr/bin anytime soon ;-).
>
> Grant.
>
> I was unaware of some of them (todos/fromdos for one), and not
> clever or imaginative enough to consider others on my own (e.g.,
> sed). The dos2unix was the first thing I came across after
> identifying the problem, and it solved it very neatly with not much
> mental strain on my part in two lines.
> dos2unix results.txt
> cat results.txt | mail -s Results user
Here is some less typing strain :-) (Look up the acronym "UUOC".)
mail -s Results user < results.txt
Cheers.
Jim
Well, if you're going to play bash golf:
dos2unix < results.txt | mail -s Results user
Why mention bash specifically? Maybe the OP (or some other follower)
is using some other shell.
Golf??
Anyway, you are right, that is shorter, but only if the OP doesn't
actually want to convert the file and use it for other things.
Cheers.
Jim