If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > shell script question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-04, 12:15
chatguy2020 chatguy2020 is offline
Registered User
 
Join Date: May 2003
Posts: 58
shell script question

Can somebody please tell how to capture the last but one function parameter? I tried something like this in vain,

set -A counts $*
x=${#counts[*]}
y=`expr $x -1`
filename="$(y)" # I tried some of these ...

Can we do it like that?

Thanks again!
Reply With Quote
  #2 (permalink)  
Old 04-13-04, 12:38
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
Tout simplement :

eval filename=\$$(($# -1))
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 04-13-04, 13:33
chatguy2020 chatguy2020 is offline
Registered User
 
Join Date: May 2003
Posts: 58
Thanks a lot for the replies aigles! Also, can you tell how to pass & return an array from a function?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On