bash - POSIX "sort -n" alpha characters between zero and 1? -
i'm having trouble getting posix "sort" behave way want to. when sorting numeric file names, start letters show between 0 , 1.
why happen?
is there different sort option can use achieve desired result?
$touch 0 1 $ls | sort -n
desired output: 0 1 a
actual output: 0 1
in gnu implementation, "-g" want, that's not posix. unfortunately, means can't use it.
if want explicitly sort output as
- first numerically sorted files 0, 1, 2, 11, 222, , after
- all other files sorted
you can example with
cat <(ls -1 | grep '^[0-9]' |sort -n) <(ls -1 | grep -v '^[0-9]' | sort)
so catenate output of 2 commands
- sort numerically files begins numbers, and
- sort other files (what aren't begins numbers)
but, works bash
, don't know how bash posix, if bash
not ok can use temporary files...
Comments
Post a Comment