From owner-freebsd-questions@FreeBSD.ORG Sun Nov 29 05:56:55 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 973B6106566C for ; Sun, 29 Nov 2009 05:56:55 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from server505.appriver.com (server505e.appriver.com [98.129.35.9]) by mx1.freebsd.org (Postfix) with ESMTP id 61ECB8FC12 for ; Sun, 29 Nov 2009 05:56:55 +0000 (UTC) X-Policy: GLOBAL - maxiscale.com X-Primary: psteele@maxiscale.com X-Note: This Email was scanned by AppRiver SecureTide X-ALLOW: psteele@maxiscale.com ALLOWED X-Virus-Scan: V- X-Note: Spam Tests Failed: X-Country-Path: UNITED STATES->UNITED STATES->UNITED STATES X-Note-Sending-IP: 98.129.23.14 X-Note-Reverse-DNS: ht01.exg5.exghost.com X-Note-WHTLIST: psteele@maxiscale.com X-Note: User Rule Hits: X-Note: Global Rule Hits: 112 113 114 115 119 120 131 218 X-Note: Mail Class: ALLOWEDSENDER X-Note: Headers Injected Received: from [98.129.23.14] (HELO ht01.exg5.exghost.com) by server505.appriver.com (CommuniGate Pro SMTP 5.2.14) with ESMTPS id 14958855 for freebsd-questions@freebsd.org; Sat, 28 Nov 2009 23:56:55 -0600 Received: from mbx03.exg5.exghost.com ([169.254.1.164]) by ht01.exg5.exghost.com ([98.129.23.14]) with mapi; Sat, 28 Nov 2009 23:56:54 -0600 From: Peter Steele To: "freebsd-questions@freebsd.org" Date: Sat, 28 Nov 2009 23:56:50 -0600 Thread-Topic: Sorting a device list Thread-Index: AcpwizKwuqMBbrDwROeBXfqQFB/h9QALThCA Message-ID: <7B9397B189EB6E46A5EE7B4C8A4BB7CB33BBEADA@MBX03.exg5.exghost.com> References: <7B9397B189EB6E46A5EE7B4C8A4BB7CB33BBEAB5@MBX03.exg5.exghost.com> <87hbsexjd7.fsf@kobe.laptop> In-Reply-To: <87hbsexjd7.fsf@kobe.laptop> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: Sorting a device list X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2009 05:56:55 -0000 I had tried that. It doesn't work: # ls -d1 /dev/ad* | sort -n /dev/ad10 /dev/ad4 /dev/ad6 /dev/ad8 I want the ad10 to appear last... -----Original Message----- From: Giorgos Keramidas [mailto:keramida@ceid.upatras.gr]=20 Sent: Saturday, November 28, 2009 4:31 PM To: Peter Steele Cc: freebsd-questions@freebsd.org Subject: Re: Sorting a device list On Sat, 28 Nov 2009 11:48:18 -0600, Peter Steele wr= ote: > Can anyone recommend a quick and dirty way to sort a device list? For exa= mple, 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.