From owner-freebsd-arch Wed Mar 6 12: 5:50 2002 Delivered-To: freebsd-arch@freebsd.org Received: from softweyr.com (softweyr.com [65.88.244.127]) by hub.freebsd.org (Postfix) with ESMTP id E285237B416 for ; Wed, 6 Mar 2002 12:05:46 -0800 (PST) Received: from mail.dobox.com ([65.88.244.102] helo=softweyr.com) by softweyr.com with esmtp (Exim 3.35 #1) id 16ihfV-000Igp-00 for arch@freebsd.org; Wed, 06 Mar 2002 13:05:46 -0700 Message-ID: <3C862030.9080108@softweyr.com> Date: Wed, 06 Mar 2002 13:57:04 +0000 From: Wes Peters Organization: Softweyr LLC User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:0.9.8) Gecko/20020222 X-Accept-Language: en-us MIME-Version: 1.0 To: arch@freebsd.org Subject: Sorting and Matching options for ls(1) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At the request of several FreeBSD users, I have developed the following two options for ls(1): -M Display files that match the specified types only. The file types are specified by a single character as in strmode(3), with the option to specify regular files as ``r'' instead of ``-'' if needed. -S Explicity specify the sorting order. The sorting flags are: 0 No sorting. n Sort by filename (default). u File owner user id. g File owner group id. s File size. a File access time (same as -u but does not modify printed output). c File change time (same as -c but does not modify printed output). m File modification time (same as -t but does not modify printed output). t File type, sorted in lexical order as displayed by strmode(3). The -S options change only the sorting order, so it is possible to list the change time while sorting by the access time with: ls -l -c -Sa The code to accomplish both of these adds only 1788 bytes to /bin/ls. The option keyletters S (for Sort) and M (for Match) were carefully chosen to be mnemonic while not conflicting with recent Posix standards or with GNU ls. My current patch against 4.5-RELEASE is available at ftp://softweyr.com/pub/softweyr/ls.diff I plan to create a patch against -CURRENT today or tomorrow. Suggestions, comments, and "don't do thats" all welcome. I hope to achieve enough consensus to commit this in the next few days, as I am going to be quite busy for the next few weeks starting this Sunday. Thank you. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message