![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing global variable to a function which is called by another function | sars | Shell Programming and Scripting | 4 | 06-30-2008 12:39 PM |
| passing a variable inside a variable to a function | KingVikram | UNIX for Dummies Questions & Answers | 2 | 01-14-2008 08:28 PM |
| Passing a unix variable value to a Plsql function | cobroraj | UNIX for Advanced & Expert Users | 1 | 10-30-2007 06:59 AM |
| Passing a variable name to be created within a function | 435 Gavea | Shell Programming and Scripting | 2 | 02-04-2004 03:20 PM |
| Passing Argument to Function | AkumaTay | UNIX for Dummies Questions & Answers | 2 | 10-18-2001 07:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
passing variable to function
Hi,
I am trying to sum up numbered columns and in order to tidy up the program I have wrote a function to do the adding of some numbers. I have a problem though with passing a variable to the function in the UNIX bash shell. The function only gives the first number in the variable list and does not add the rest. Can a variable not be passed to the function or am I missing something quite obvious here. The function that I wrote and the function call is shown below; function add_num () { sum=0 for NUM in $1 do sum=`expr $sum + $NUM` done } I call this function by function_name Variable_name as so: add_num $column1 add_num $column2 Very puzzled, Knotty. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|