/bin/sh help needed

Scott Prive Scott.Prive at storigen.com
Tue Apr 23 15:17:35 EDT 2002


Your solution works... what more do you want?
Bash has a face that NO mother could love :-)

Seriously, if you want a "more satisfying-looking solution", use Perl (or better yet, Python). Bonus: either one is faster than Bash.

Then again, "sh" is the preferred solution for init scripts so I don't know if my suggestion is appropriate to your intended use.


One sh technique: Use something a colon as a delimiter, and use awk to break up the string:

dfcheck -s 10 `echo '$PATHS' | awk -F: '{print $1}'`

and "for" loop through $1 through $3 for example.
( $0 is not the first element in awk.. it's the whole command-line invocation with arguments. )


-Scott



-----Original Message-----
From: David Kramer [mailto:david at thekramers.net]
Sent: Tuesday, April 23, 2002 9:58 AM
To: BLU Boston Linux Unix group
Subject: /bin/sh help needed


I have a string in a /bin/sh script.  In that script I have a variable 
with a space-separates list of file widcards, like:
	paths="/etc/r* /var/adm/* /home/dkramer/e*"

I have another script that I want to call from this one, passing these 
wildcards as separate arguments, like:
	dfcheck -s 10 ${paths}

Every combination of single quotes, double quotes, and escaping seems to 
either send it all as one argument, or send it all as separate arguments, 
but each argument is quoted.  The only solution I found, which works but 
is "unsatisfying", is 
	echo "$paths" | xargs dfcheck -s 10

Any ideas?

-------------------------------------------------------------------
DDDD   David Kramer                   http://thekramers.net
DK KD
DKK D  Intelligence is knowing how to build a nuclear bomb.
DK KD  Wisdom is knowing how not to need them.
DDDD                              Shaggy 2 Dope- Insane Clown Posse

_______________________________________________
Discuss mailing list
Discuss at blu.org
http://www.blu.org/mailman/listinfo/discuss



More information about the Discuss mailing list