Search Results

Search: Posts Made By: Chubler_XL
36,067
Posted By Chubler_XL
Say you have four values in variable VALS like...
Say you have four values in variable VALS like this a b c d then you can build an array containing these with a simple set statement.
$ set VALS="a b c d"
$ set master_array = ( $VALS )
$ echo...
36,067
Posted By Chubler_XL
Assigning the array with set will automatically...
Assigning the array with set will automatically size to the input eg.

$ set arr=(1 2 3 4 5)
$ set newarr=(1 2 3 4 5 6 7 8 9 10)
$ echo ${#arr}
5
$ set arr=( $newarr:q )
$ echo ${#arr}
10
36,067
Posted By Chubler_XL
Not quite sure what you mean by input as an array...
Not quite sure what you mean by input as an array value. It's fairly straight forward to pre-load an array with fixed values or copy an existing array into another:

$ set ar=(10 165 22 156)
$...
36,067
Posted By Chubler_XL
You could try this: set ar=() set x=10 ...
You could try this:

set ar=()
set x=10
foreach i ( `seq $x`)
set ar=($ar:q " ")
end
echo ${#ar}

However with my csh (tchs 6.22.01) using $arr:q to print array elements with quotes...
Showing results 1 to 4 of 4

 
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy