clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Better stat command in OS X

Filed under: System— Tagged with: bash, shell, snippets

Here’s how to make the stat command more readable.

When getting info from a file, like it's access rights and owner, the stat is the goto command:

$ stat path/to/file.sh
16777220 51760568 -rwxrwxr-x 1 hilja staff 0 1473 "Jan 18 17:32:02 2015" "Jan 18 17:31:45 2015" "Jan 18 17:31:50 2015" "Jan 18 17:31:45 2015" 4096 8 0 path/to/file.sh

That’s not very human readable. Use -x flag to get that:

$ stat -x path/to/file.sh
  File: "path/to/file.sh"
  Size: 1473         FileType: Regular File
  Mode: (0775/-rwxrwxr-x)         Uid: (  501/   hilja)  Gid: (   20/   staff)
Device: 1,4   Inode: 51760568    Links: 1
Access: Sun Jan 18 17:32:02 2015
Modify: Sun Jan 18 17:31:45 2015
Change: Sun Jan 18 17:31:50 2015

Much better :)

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @hiljaa if you want to make a correction etc.

  • © 2021 Antti Hiljá
  • About
  • Follow me in Twatter → @hiljaa
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • console.log('Smash the patriarchy!')
  • I love u!