[Novalug] Ubuntu Dependencies
novalugml at jgcomp.com
Wed Feb 18 00:20:55 EST 2009
On Tue, Feb 17, 2009 at 02:14:22PM -0500, James Ewing Cottrell 3rd wrote:
> I have already told you.
If you did, I missed it.
> The syntax is almost like, but different enough from C and sh.
perl seems that way to many people.
> Perhaps my real problem is trying to mix awk on the
> command line along with sh syntax. I dunno, trying to get the fields
> printed how I want with whitespace included always seemed awkward, pun
> intended. I can't remember exactly.
While shell scripts with embedded pieces of perl certainly do exist,
they are overwhelmed by scripts containing pieces of awk. So others
don't seem to have your problem. Is your problem with whitespace
because you don't know how to use printf, the one common output
function between shell, c, awk, perl, ...
Yes, perl has the format statement, but shell and c do not.
> ... . Now if you wish to say that Perl is an Abomination and that
> you should use Ruby or Python, fine, but then the argument just changes
> flavors and AWK still loses.
> AWK is just unnecessary.
Didn't you just indicate perl is also unnecessary as Ruby or Python
are suitable replacements for perl.
> Remember, so if you're smart, you'll invest your time elsewhere,
> including stupid discussions like this one :)
Let's see, "not worth my salt" if I don't know perl and "not smart"
if I invest time in awk. Just to clarify, I've been a trainer and
developer in both languages.
> YES, I AM recommending a sh while/read loop! For starters, there no
> fork/exec. But mainly, because it shows what is possible with sh.
Actually that is not true. While there may not be an exec, there
certainly will be a fork for a shell control structure used as a
filter. Even if the control structure is at the end of a pipeline
it is still a separate process in bash though in that case ksh93
will run it in the parent process.
I don't advocate using a language's feature just to show what
is possible. I think it is more reasonable to use a feature
when it is appropriate. Your loop was not appropriate.
> Unfortunately, many of the Elders brains were rotted by (t)csh and its
> ilk, and erudite sh programming suffered because we were thinking in the
> wrong (csh) terms. Have you ever noticed that most sh scripts suck? It
> seems like the writers don't really understand what sh can really do.
It has been said that my large shell scripts resemble C code.
Don't know if that is good or bad.
> I only became fully aware when I switched to ksh and bash. Wow, you can
> pipe and redirect not only thru while, but thru if and case as well!
ksh93 has been my prefered shell since ... well since about 93.
> Learn and Master the Existing Tools first before you seek out others.
> CUT is a (Mostly) Worthless System V Abomination. Why? Because there is
> no -w switch that cuts on whitespace. For things like /etc/passwd, which
> are delimited by a fixed character, it's useful, but more and more files
> are Whitespace Delimited. Don't try using cut on /etc/fstab.
I think your L&M comment is extremely fitting here. You reject a
tool designed to do a particular task because it doesn't do another.
Gee, lets not use screws because you can't drive them with hammers.
Where suitable it is smaller, more efficient, doesn't need to
interpret/compile its script before starting, and is builtin to
some shells so may not even need a fork/exec.
> BTW, PRINTF is worthless too because "printf %c 27" doesn't output an
> escape. Grrrrr!
See, I knew you did not know how to use awk's printf. It outputs an
escape on systems I've tried it on.
But why bother when you can do printf "\e" to print the esc char.
You may be trying the shell builtin printf or the printf command
in /usr/bin. If so, it is not a printf problem, its a shell problem.
The shell does not convert the string 27 into an integer.
> AWK is crufty, outdated, serves no useful niche, and deserves to die.
> P.S. If you ask Really Nicely, I'll tell you How I really Feel instead
> of Beating Around the Bush. :)
Well as long as you know the one true reality for the entire world,
I'll probably live in a dream world of my own.
I'll use shell and awk for most of my scripting, using perl mostly
for more complex tasks, especially when I think there may be a
cpan module that will do most of the heavy lifting.
Jon H. LaBadie jon at jgcomp.com
12027 Creekbend Drive (703) 787-0884
Reston, VA 20194 (703) 787-0922 (fax)
More information about the Novalug