Doug-
It won't let you post from other than the address you are subscribed as.
---------- Forwarded message ----------
Date: Sun, 24 Sep 2000 21:37:30 -0400
From: owner-tomsrtbt
To: owner-tomsrtbt
Subject: BOUNCE tomsrtbt: Non-member submission from [Douglas Bollinger
<[EMAIL PROTECTED]>]
>From [EMAIL PROTECTED] Sun Sep 24 21:37:29 2000
Received: from shell.pacifier.com (IDENT:[EMAIL PROTECTED] [199.2.117.66])
by toms.net (8.9.1a/8.8.8) with ESMTP id VAA00627
for <[EMAIL PROTECTED]>; Sun, 24 Sep 2000 21:37:28 -0400
Received: (from dougb@localhost)
by shell.pacifier.com (8.9.3/8.9.3) id RAA13097
for [EMAIL PROTECTED]; Sun, 24 Sep 2000 17:44:39 -0700 (PDT)
Date: Sun, 24 Sep 2000 17:44:39 -0700
From: Douglas Bollinger <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: xargs awk script
Message-ID: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.95.7i
Below is a simple xargs awk script that I pounded out last week during
breaks at work. This is a work-in-progress; it's not meant for
general use yet. I thought I would post it on the mailing list and
see what you guys think.
Caveats:
This is the first bit of programming I did since my C-64. :) Test at
your own risk. I'm sure there are better ways of doing this, but the
script seems well behaved. I based this off a perl xargs script that
I found in a archive of perl utilties, but its different since awk is
not perl. Porting this was actually kinda fun; I learned quite a bit
about perl, xargs and awk.
I did a bit more testing on it in the tomsRTBT enviroment; it works
fine but seems to have a line limit. It worked well with a 20000 line
limit, which should be made a default.
The script uses the common.awk file in tomsRTBT, so it is called from
a one-liner like other awk scripts in tomsRTBT.
I'm posting this from my win box, so there's a good chance the file
will get mangled with ^M's. If you wish to use it, you probably will
have to use your favorite dos2unix conversion utility. If this is a
hastle, let me know and I'll post a tarball you can d/l. I'm posting
it here because I thought some of you might just want to read it.
I'm interested in feedback, good and bad. Email me directly or post
here.
This is the onliner that calls the common & xargs scripts. The first
line is the filename, xargs, and inbetween the dashes is the actual
script.
xargs
---------------
#!/bin/sh
awk -f `dirname $0`/common.awk -f $0.awk -- "$@"
---------------
This is the main script below:
---------------
function beginfile(j) {}
function endfile(j) {}
BEGIN {
while ((c = getopt(ARGC, ARGV, "tn:l:")) != -1 ) {
if (c == "t")
trace++
else if (c == "n")
numargs = Optarg
else if (c == "l")
numlines = Optarg
else usage()
}
for (i = 1; i < Optind; i++)
ARGV[i] = ""
for (i = Optind; i < ARGC; i++) {
command = command ARGV[i] " "
ARGV[i] = ""
}
if (!command)
command = "echo "
}
{
for (i = 1; i <= NF; i++) {
argcount++
arguements[NR, i - adjust] = $i
if (numargs && (argcount >= numargs)) {
outargs(arguements)
argcount = 0
adjust = i
if (!(NF-i))
NR = 0
}
}
adjust = 0
if (numlines && (NR = numlines)) {
outargs(arguements)
NR = 0
}
}
END {
if (arguements[1,1])
outargs(arguements)
exit 0
}
function outargs(arguements, x, i, output)
{
for (x = 1; x <= NR; x++) {
for (i = 1; arguements[x,i]; i++) {
output = output arguements[x,i] " "
arguements[x,i] = ""
}
}
if (trace)
print command output
system(command output)
}
function usage()
{
print "Usage: xargs [-t] [-n max-args] [-l max-lines] " \
"[command [initial-arguments]]" > "/dev/stderr"
exit (1)
}
---------------