Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the stat command on OS X to display a file or directories creation date / time?

Tags:

terminal

macos

How to use the stat command on OS X to display a file or directories creation date / time?

stat filename

What options to use with the f flag?

like image 544
gornvix Avatar asked Apr 23 '15 14:04

gornvix


People also ask

How can I tell when a Mac file was created?

Answer: A: You can get the creation date & the last modified date in Finder using Get Info or selecting the file in column view or list view.

Can you use stat on a directory?

The stat command can also work against directories. In this case, we see that there are a number of links. Here, we're looking at a file system. Notice the Namelen (name length) field.

How do you display the statistics of a file in Linux?

The stat is a command which gives information about the file and filesystem. Stat command gives information such as the size of the file, access permissions and the user ID and group ID, birth time access time of the file. Stat command has another feature, by which it can also provide the file system information.

Which command is used to determine state files?

stat command is a useful utility for viewing file or file system status.


1 Answers

This will give you the creation date, output it and convert the time to a more readable sequence :

stat -f %SB file/directory

Do note that Mac OS X keeps track of the creation time of a file/directory, whereas Linux doesn't since it isn't required by POSIX. You can find more information here

For more informations about the format you can use for the stat command, go check the man page for stat(1) here.

like image 79
chesh Avatar answered Sep 18 '22 12:09

chesh