Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/bin/sh help needed



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




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org