Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何在Bash中对数组进行排序_Arrays_Bash_Sorting - Fatal编程技术网

Arrays 如何在Bash中对数组进行排序

Arrays 如何在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=$(排序输

我需要在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=$(排序输入可以在文件中给出,还是应该在bash变量中给出?