Sorting a device list

Giorgos Keramidas keramida at ceid.upatras.gr
Sun Nov 29 00:30:47 UTC 2009


On Sat, 28 Nov 2009 11:48:18 -0600, Peter Steele <psteele at maxiscale.com> wrote:
> Can anyone recommend a quick and dirty way to sort a device list? For example, if I do this:
>
> ls /dev/ad* | sort
>
> I get something like this:
>
> /dev/ad10
> /dev/ad4
> /dev/ad6
> /dev/ad8

Just use `sort -n':

    ls -d1 /dev/ad* | sort -n

It should work fine even when there are non-numeric prefix strings.




More information about the freebsd-questions mailing list