Arrays 如何在Bash中对数组进行排序
我需要在bash中编写排序代码数组函数,第一个输入是number of numberArrays 如何在Bash中对数组进行排序,arrays,bash,sorting,Arrays,Bash,Sorting,我需要在bash中编写排序代码数组函数,第一个输入是number of number 和结束返回数组排序例如::input 5 2 4 10 1 4返回1 2 4 4 10以下脚本对数组排序a,其中数组中的第一个元素是数组中的元素数。结果存储在变量b #! /bin/bash IFS=$'\n' a=( 3 3 2 1 ) b=$(sort <<< "${a[*]:1}") echo ${b[*]} #/bin/bash IFS=$”\n“a=(3 2 1) b=$(排序输
和结束返回数组排序例如::input 5 2 4 10 1 4返回1 2 4 4 10以下脚本对数组排序
a
,其中数组中的第一个元素是数组中的元素数。结果存储在变量b
#! /bin/bash
IFS=$'\n' a=( 3 3 2 1 )
b=$(sort <<< "${a[*]:1}")
echo ${b[*]}
#/bin/bash
IFS=$”\n“a=(3 2 1)
b=$(排序输入可以在文件中给出,还是应该在bash变量中给出?