I'm using stat like this:

stat -f "%Sp %p %l %Su %u %Sg %g %z %a %N %Y"  /*

I need also to tell if the file is hidden or not (MacOS). The . notation is not enough. MacOS hides more files.

For example, this is what I need:

ls -lO                                                                
total 9
drwxrwxr-x  32 root  admin  sunlnk            1024 Jun  4 22:00 Applications
drwxr-xr-x  66 root  wheel  sunlnk            2112 Feb 18 23:23 Library
drwxr-xr-x@  9 root  wheel  restricted         288 Jan  1  2020 System
drwxr-xr-x   7 root  admin  sunlnk             224 May 18 08:12 Users
drwxr-xr-x   4 root  wheel  hidden             128 Jun  7 12:49 Volumes
drwxr-xr-x@ 38 root  wheel  restricted,hidden 1216 Jan  1  2020 bin
drwxr-xr-x   2 root  wheel  hidden              64 Jun  6  2020 cores
dr-xr-xr-x   3 root  wheel  hidden            4602 Jun  1 14:24 dev
lrwxr-xr-x@  1 root  wheel  restricted,hidden   11 Jan  1  2020 etc -> private/etc

I need to run it as one command for sake of processing speed. My goal is all from my above stat plus the 5th column of the ls command. Any hints?

I've noticed that %T prints @ for hidden items. It could however show it also for other reasons. Can this be used or not?

It no stat solution is found, is there a way to merge stat results with the extra ls -lO column on a command line?


1 Answer 1


If macos stat is like FreeBSD's, the flags can be expressed in the format specification with %f for the numeric form or %Sf for the decoded text form like in ls -lo.

See man stat, man chflags and man ls on your system for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .