1 Replies - 550 Views - Last Post: 30 November 2008 - 10:24 PM Rate Topic: -----

#1 Next2Nothing  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-November 07

Simple bash question

Posted 30 November 2008 - 10:09 PM

I'm trying to be able to accept multiple arguments for a program, the way I've devised to go about this is to loop through the arguments list ($@) using the number of arguments ($#) as a max to stop at. My question is that in this format I have to call the specific command line argument variable name (1$, 2$, etc), and I have been unable to successfully set this.


I'm really new to bash so please excuse my ignorance.

crntarg=0
while [ $crntarg -ne $# ]
do
if [ $(($crntarg)) = "-n" ]; then <-------How do you define this variable name

...

fi
done

This post has been edited by Next2Nothing: 30 November 2008 - 10:11 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Simple bash question

#2 Next2Nothing  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-November 07

Re: Simple bash question

Posted 30 November 2008 - 10:24 PM

Nevermind, I found an easier way to parse through the arguments. If you are having a similar issue look at the command shift and possibly a case statement setup.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1