For instance, the array is
link2_pathname
link1_pathname
link3_pathname
How can I get the array like below.
link1_pathname
link2_pathname
link3_pathname
Thanks a lot in advance!
For instance, the array is
link2_pathname
link1_pathname
link3_pathname
How can I get the array like below.
link1_pathname
link2_pathname
link3_pathname
Thanks a lot in advance!
pipe a loop to sort.
a=(l2 l3 l1)
b=($(for l in ${a[@]}; do echo $l; done | sort))
you probably need to watch out for the IFS when handling string values containing spaces.
@ or * expand to all entries in an array. you might want to access or print the values contained by echo ${a[@]}. ${a} probably just returns l2 because the default IFS, which is a space is recocognized and therefor cut off due to uncomplete variable expansion.