coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stat(1) print formats


From: Ken Irving
Subject: Re: stat(1) print formats
Date: Sun, 23 Nov 2014 23:59:25 -0900
User-agent: Mutt/1.5.20 (2009-06-14)

On Sat, Nov 22, 2014 at 02:00:39PM -0900, Ken Irving wrote:
> I'd also be interested in having stat(1) -c or --printf formats more
> suited to simple parsing in scripts.  %N is effectively a 'pretty print'
> form, fairly complicated to parse, and the same might be said for %F
> since it uses multiple words for some types.  If new format patterns
> might be considered, I concur with the above suggestion for one that
> produces just the unquoted link value (as readlink(1) would provide);
> and a terse type-showing pattern, e.g., maybe using one-letter values
> like find(1) -type uses.

I've attached a draft patch adding format pattern %p to stat(1) to output
one-letter codes for file type, as used by find(1) -type.  The choice of
%p is arbitrary, but it seems to be available, and could perhaps suggest
'tyPe' as a mnemonic.

    ken@kimball:~/coreutils-hacks/coreutils/
    $ mkfifo fifo
    $ src/stat --printf "%12n%24F\t%p\n" configure src INSTALL fifo 
/dev/{ram0,tty,log}
       configure            regular file    f
             src               directory    d
         INSTALL           symbolic link    l
            fifo                    fifo    p
       /dev/ram0      block special file    b
        /dev/tty  character special file    c
        /dev/log                  socket    s

Ken

Attachment: stat-type-patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]