s****l 发帖数: 10462 | 1 是不是苹果的sh command和linux/ubuntu等不一样?我想随机sort,结果在mac
terminal里面不行
怎么改过来? | Q*********r 发帖数: 69 | 2 这个需要gnu sort, 你用macports装一下coreutils应该就有了.
【在 s****l 的大作中提到】 : 是不是苹果的sh command和linux/ubuntu等不一样?我想随机sort,结果在mac : terminal里面不行 : 怎么改过来?
| I*********t 发帖数: 5258 | 3 Mac的sort虽然也是gnu sort,但是比较老。你可以用其它方法实现随机分选,比如
$ cat SortedFile.txt | perl -wnl -e '@f=<>; END{ foreach $i (reverse 0 .. $#
f) { $r=int rand ($i+1); @f[$i, $r]=@f[$r,$i] unless ($i==$r); } chomp @f;
foreach $line (@f){ print $line; }}'
这个应该是跨平台的 |
|