How to sort integer array in KornShell. Found this link, KornShell Sort Array of Integers but it seems to be not working and throwing error.
Code:
NUM_ARR[1]=-1
NUM_ARR[2]=-2
NUM_ARR[3]=-3
NUM_ARR[4]=-4
NUM_ARR[5]=-5
NUM_ARR[6]=-6
NUM_ARR[7]=-7
for file in /home/fimsctl/datafiles/outbound/timelog/timelog_file_*.csv ; do
SORTED_NUM_ARR=`($(printf "%s\n" ${NUM_ARR[@]} | sort -n))`
echo ${SORTED_NUM_ARR[*]}
done
Output:
testb.ksh[118]: -7: not found
You can use
sort
with process substitution: