[kwlug disc.] bash script basics

Abram Hindle abez at abez.ca
Sat Feb 10 14:38:11 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is insecure and a hack but it should work:

perl -nle 's/#.*$//; system("yourscript $_") if (/\d/);'

egrep '[0-9]' | sed -e 's/\#.*$//' | tr '\n' '\000' | xargs -0 -i echo
yourscriptname {} | sh -x

Note these are pretty trusting of your input.

If you're ok with your script being run with no commandline options you
could just:
awk '{print "yourscript " $0}' < yourdata | sh -x
or
awk '{system("yourscript " $0)}' < yourdata

abram

Richard Weait wrote:
> I'm looking for a bash script solution for what must be a common
> situation.  But I don't have the script-fu to solve this.  And my
> google-fu has failed me, too.
> 
> A CLI tool accepts three arguments.  I'd like to feed the CLI tool
> with a series of these coordinates.  And I'd like to have comments in
> the file that are ignored rather than sent to the CLI.  Surely this is
> a 5 or 6 line script. No?
> 
> How do I feed the lines of arguments to my command?
> 
> I suppose perl could do this in four punctuation symbols.
> 
> The data file might look like this.
> 
> #
> # this is a fake data file
> #
> 
> 1 2 3 # three whitespace separated numbers
> 4 5 6
> 7 8 9
> 10 11 12  # each number up to 5 or 6 digits
> # comments
> 13 14 15 # real data is arbitrary, not sequential
> 16 17 18
> 
> Help?
> _______________________________________________
> KWLUG-Disc mailing list
> KWLUG-Disc at kwlug.org
> http://listserv.kwlug.org/mailman/listinfo/kwlug-disc
> 
> 
> ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** CLASSIFY
> succeeds; success probability: 1.0000  pR: 40.7425
> Best match to file #0 (/home/abez/crm/nonspam.css) prob: 1.0000  pR:
> 40.7425  Total features in input file: 3504
> #0 (/home/abez/crm/nonspam.css): features: 378059, hits: 4668752, prob:
> 1.00e+00, pR:  40.74 #1 (/home/abez/crm/spam.css): features: 2082284,
> hits: 3948092, prob: 1.81e-41, pR: -40.74

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFzh8inOrfa1yW8IURApsXAJ91ZkfPoMaC5j67NmUOxw3ZWzYIxACgg+Fw
CILH7/OZ2ekmAe81958spdE=
=6Uqa
-----END PGP SIGNATURE-----


More information about the KWLUG-Disc mailing list