From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15689 invoked by alias); 27 Feb 2012 17:39:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16801 Received: (qmail 305 invoked from network); 27 Feb 2012 17:39:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at dan.emsphone.com does not designate permitted sender hosts) Date: Mon, 27 Feb 2012 11:31:51 -0600 From: Dan Nelson To: TJ Luoma Cc: zsh-users@zsh.org Subject: Re: How to find owner of file or folder? Message-ID: <20120227173150.GH59682@dan.emsphone.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 8.2-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.2 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Mon, 27 Feb 2012 11:31:51 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 In the last episode (Feb 27), TJ Luoma said: > This is the only way that I know of to get the username who owns a > certain file or folder, such as /usr/local/ > > command ls -ld /usr/local | awk '{print $3}' > > (or `ls -dn` if you want the number instead of the name) > > but that seems fairly inelegant. > > Is there a better way? $ zmodload zsh/stat $ zstat -H fileinfo /usr/local $ echo $fileinfo[uid] 0 $ ls -ld /usr/local drwxr-xr-x 42 root wheel 42 Feb 19 17:05 /usr/local/ $ typeset fileinfo fileinfo=(atime 1313171206 blksize 4096 blocks 5 ctime 1329692755 device 4201426224 gid 0 inode 3366 link '' mode 16877 mtime 1329692755 nlink 42 rdev 4294967295 size 42 uid 0 ) -- Dan Nelson dnelson@allantgroup.com