Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/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
循环中的bash排序错误_Bash_Sorting - Fatal编程技术网

循环中的bash排序错误

循环中的bash排序错误,bash,sorting,Bash,Sorting,我试图根据第二列(选项-k2)对bash循环中的一组文件进行数字排序(选项-n): 但是这种方法不能正常工作。有人知道吗? 提前谢谢 这是我得到的输出: for ch_perm in {0..99}; do > for ch_set in {1..15}; do > Display all 1504 possibilities? (y or n) 11.results.21 13.results.35 15.results.49 3.results.61 5.r

我试图根据第二列(选项-k2)对bash循环中的一组文件进行数字排序(选项-n):

但是这种方法不能正常工作。有人知道吗? 提前谢谢

这是我得到的输出:

for ch_perm in {0..99}; do
> for ch_set in {1..15}; do 
> 
Display all 1504 possibilities? (y or n)
11.results.21   13.results.35   15.results.49   3.results.61    5.results.74    7.results.88 [...]

>  -k 2 $ch_set.results.$ch_perm > sortedbyscore2/$ch_set.results.$ch_perm ; 
> done
> done
-bash: -k: command not found
-bash: -k: command not found
-bash: -k: command not found (many many times)

您已经使用了制表符缩进脚本,当您将脚本粘贴到终端中时,这会使bash感到困惑,最终会触发bash的双制表符自动完成。您可以看到,发生这种情况时,“排序”已丢失


使用空格缩进,或者将此脚本放入文件中并从那里运行。

您使用制表符缩进脚本,当您将脚本粘贴到终端时,这会使bash感到困惑,最终使用双制表符触发bash的自动完成。您可以看到,发生这种情况时,“排序”已丢失

使用空格缩进,或者将此脚本放入文件中并从中运行

for ch_perm in {0..99}; do
> for ch_set in {1..15}; do 
> 
Display all 1504 possibilities? (y or n)
11.results.21   13.results.35   15.results.49   3.results.61    5.results.74    7.results.88 [...]

>  -k 2 $ch_set.results.$ch_perm > sortedbyscore2/$ch_set.results.$ch_perm ; 
> done
> done
-bash: -k: command not found
-bash: -k: command not found
-bash: -k: command not found (many many times)