![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Array inside an array | manas_ranjan | UNIX for Advanced & Expert Users | 5 | 06-10-2008 03:25 PM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 09:42 AM |
| how do I make dynamic parameter names? Or get the value of a parameter evaluated twi | Awanka | Shell Programming and Scripting | 2 | 04-19-2007 10:37 PM |
| parameter | u263066 | Shell Programming and Scripting | 5 | 10-12-2006 04:46 AM |
| Array as a Parameter | heyindy06 | Shell Programming and Scripting | 3 | 03-31-2006 04:00 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Array as parameter
Can I pass and array as a function paramter?
Code:
#!/bin/bash
a1[1]=one
a1[2]=two
a2[1]=one
a2[2]=two
function f1()
{
array1copy=( ${1[@]} )
array2copy=( ${2[@]} )
echo "${array1copy[@]}"
echo "${array2copy[@]}"
}
f1 "${a1[@]}" "${a2[@]}"
Thank you |
|
||||
|
It is possible, but not without any effort:
Code:
function caller {
typeset array[1]="foo"
typeset array[2]="bar"
callee array
return 0
}
function callee {
typeset -i iCnt=0
(( iCnt = 1 ))
while [ $iCnt -le $(eval print \${#$1[*]}) ] ; do
print - $(eval print \${$1[$iCnt]})
done
return 0
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|