Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 1999 01:15:11 -0800 (PST)
From:      byron@omix.com (Byron Brummer)
To:        zen@buddhist.com (G. Adam Stanislav)
Cc:        byron@omix.com, freebsd-doc@FreeBSD.ORG
Subject:   Re: Converting text files
Message-ID:  <199903150915.BAA11814@thrush.omix.com>
In-Reply-To: <3.0.6.32.19990315024432.007cf9a0@mail.bfm.org> from "G. Adam Stanislav" at "Mar 15, 99 02:44:32 am"

next in thread | previous in thread | raw e-mail | index | archive | help
"G. Adam Stanislav" <zen@buddhist.com> wrote:
> At 19:58 14-03-1999 -0800, you wrote:
> >	What's there to learn? 
> 
> I did not say there was anything to learn. I was replying to a message
> that said there was new syntax to learn with tuc. There isn't. (All you do
> is "tuc infile outfile", or "dosprogram | tuc | unixprogram".)

	I may be picking a nit, however the above is considered to be the
	"syntax".  Even a program that takes no arguments at all has a
	syntax, albeit a void one.

	To use tuc, one would still need to view a man page or similar.  One
	can not assume anything.  For instance, one might assume that it
	worked like this (as many commands do):

		tuc file_one file_two > outfile

	If one did, they would be very disappointed to find file_two gone. 
	So yes, there still is new syntax to learn or at least review when
	needed.

	One of the reasons for the inclusion of the perl command is that it
	automatically saves a backup file of the original, thus helping to
	prevent disaster.  Another reason is that it gets people a little
	more familiar with perl in general.  The command given in the
	handbook is:

		perl -i.bak -npe 's/\r\n/\n/g' file

	This same code can be easily changed to do other simple tasks:

		perl -i.bak -npe 's/teh/the/g' file

	Or just slightly more complex:

		perl -pe 's/(byron|brummer)/\u$1/ig' file

	In short, setting the user on a path to help themself when more
	complex problems arise.

> At any rate, I did not mean to start a big discussion about what is easier
> or better, and what is not. That, after all, is relative. As I said, I
> thought I was talking to the maintainer of the FAQ, and simply wanted to
> let him/her/them know there was an alternative. That's all, really. :-)

	Many holy wars have been started over far less. :-)

> By the way, tuc does not just strip carriage returns. It uses a state
> machine, so it converts files of all commonly used conventions to the Unix
> convention: cr, cr/lf, cr/lf/lf... (for more than one line - I have seen
> files like that), lf/cr, and lf alone (of course the latter does not need
> to be converted).

	Still, one line:

		s/\r|\r\n|\r\n\n|\n\r/\n/;

	Any others can be added trivially as well.  Perhaps you should pick
	up a bit of Perl? :-)

	>snip<
> I wrote it for my own use when I first got started with FreeBSD several
> months ago, and simply offered it as an option for others because I wanted
> to give something back.
> 
> I am still fairly new to FreeBSD. So please bear with me if I used the
> wrong chanel.

	We appreciate the effort and no you didn't use the wrong channel,
	however there might be better ones.

	Typically the best place for ideas such as this is an open forum,
	such as the general mailing lists and .misc newsgroups.  It's
	generally better for ideas to be openly debated before they are
	adopted in the large.

	I really would suggest picking up some perl.  It's pretty much the
	most powerful power tool you'll find anywhere.  You might even find
	yourself disliking C quite a bit after perl, most do. :-)

-- 
-Zenin (zenin@archive.rhps.org)                 Your Official ORGy sites!
 The Bawdy Caste      (Fremont, CA)                www.bawdycaste.org
 Barely Legal         (Oakland, CA)                   www.barelylegal.org
 Rocky Horror Archive (Earth, Milky Way)                 www.archive.rhps.org
 RHFC1.1 V!M!P1S2RBL24Y1980 P*B-R+20@H-D+100@W+200@T+5@P?L15@Y1990&1@(7@)!1
 C8@W3@P@& IF&-W&&-N+M1C-! MA2{RO,PQ}M{PQ}C3B15@R15@V1O+++ D?-K1S@C0!O{IS}T5@
 QNA+&+!K+!PW>&H1+! YA25+>16G{m}H{5'7"}L{CA,USA}S{f>ba12^H7k}W=


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903150915.BAA11814>