How to create a array in unix shell programming?

! /bin/bash # define a array, space to separate every item foo=(foo1 foo2) # access echo ${foo1} # add or changes foo0=bar foo2=cat foo1000=also_OK You can read the ABS "Advanced Bash-Scripting Guide.

As to your question about creating an array in a shell script, I haven't personally done it, but I found the following: linuxtopia.org/online%5Fbooks/advanced%5... Interesting how accessing elements within an array requires such a different notation.

You can try of the following type : #! /bin/bash declare -a arr i=0 j=0 for dir in $(find /home/rmajeti/programs -type d) do arri=$dir i=$((i+1)) done while $j -lt $i do echo ${arr$j} j=$((j+1)) done.

Breaks on directory names with spaces. Use a while read loop of change IFS to take care of that. – user216915 Dec 10 '09 at 6:22.

The Bourne shell and C shell don't have arrays, IIRC. In addition to what others have said, in Bash you can get the number of elements in an array: elements=${#arrayname@} and do slice-style operations: array=(apple banana cherry) echo ${arrayname@:1} # yields "banana cherry" echo ${arrayname@: -1} # yields "cherry" echo ${arrayname${#arrayname@}-1} # yields "cherry" echo ${arrayname@:0:2} # yields "apple banana" echo ${arrayname@:1:1} # yields "banana.

In ksh you do it: set -A array element1 element2 elementn # view the first element echo ${array0} # Amount elements (You have to substitute 1) echo ${#array*} # show last element echo ${array $(( ${#array*} - 1 )) }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions