Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function for loop input 1

Status
Not open for further replies.

jdespres

MIS
Aug 4, 1999
230
US
I have the following for loop ::--->

nbqueryname () {
for i in `cat $1`
do
echo "$i \c"
bpgetconfig -M $i | grep "^CLIENT_NAME"
done
}

I would like t make $1 either a single name or a file with multiple names...

Right now it's setup to take a file with multiple names...

How can I make it either or?

Thanks....

Joe Despres
 
Typed, untested:
for i in `[ -f $i ] && cat $1 || echo $i`

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OOps, sorry for the typo:
for i in `[ -f $1 ] && cat $1 || echo $1`

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is so awesome!...

I would like to put multiple entries on the command line..

Can I change $1 to $* ?

Thanks..

Joe Despres
 
To answer my own question.....

That does work!

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top