Sorting a device list

perryh at pluto.rain.com perryh at pluto.rain.com
Mon Nov 30 05:13:02 UTC 2009


Oliver Mahmoudi <olivermahmoudi at gmail.com> wrote:
> you can try to delete the /dev/ad10 entry with sed and then just
> append it to the end manually using the printf(1) utility like so:
>
> # ls /dev/ad* | sed s/"\/dev\/ad10"// | grep "/dev/ad" && printf
> "/dev/ad10\n"

Or strip the non-numerics from the beginning of each line, and put
them back after sorting:

# pfx=/dev/ad ; ls -d1 ${pfx}* | sed "s;$pfx;;" | sort -n | sed "s;^;$pfx;"


More information about the freebsd-questions mailing list