Not sure what your default shell is on your macOS or OSX, but if the stat
utility either is available (it should) or can be installed, you can do this:
$ find . -exec stat -c "%n,%w,%y,%s" {} \; # on Arch linux
$ find . -exec stat -t "%F %T" -f "%N,%B,%m,%z" {} \; # on macOS, OSX
Example of CSV output:
./.bash_history,2020-07-05 19:27:36.691875334 +0200,2020-07-05 19:27:36.691875334 +0200,54669
./.gitignore_global,2018-03-03 14:22:52.298262296 +0100,2018-03-03 14:22:52.298262296 +0100,423
...
If you are not familiar with this, I recommend you type man find
and then man stat
[1] in your terminal to get oriented. Here the short take on what you will see:
.
points to your present working directory, i.e. the directory in which you find yourself when you issue the command above. You can change that to any fully qualified directory path if you issue the command from a directory that is different from the one whose tree you want to explore
- for each file found, execute (
-exec
flag) the cmd stat
with the following output format:
On Arch Linux:
%n
fully qualified file name (file path + file basename),
%w
human readable file time of birth in the form YYYY-MM-DD HH:MM:SS +/-hhmm
with your system's numeric time zone denoted +hhmm
or -hhmm
.
Seconds' decimals are included,
%y
human-readable time of file's data's last modification, format as before
%s
total file size in bytes.
On macOS or OSX, stat
has a different implementation than that on GNU-centric platforms. I could not test for format under macOS for this answer, but in principle the correct options should be:
%N
file name,
%B
file time of birth, date time format as above, without the numeric time zone,
%m
time of file's last modification, format as with %B
,
%z
total file size.
If you want to preserve this output for result post-processing, include an output redirection to your cmd, like so:
$ find . -exec stat -t "%F %T" -f "%N,%B,%m,%z" {} \; > stat.out # on macOS or OSX
You can open your CSV output file directly from LibreOffice Calc
. If, however, you wish to produce native Excel format output, your best best is to use either perl
or python
.
The output file stat.out
will be rewritten every time you re-issue the cmd. Change its name every time to avoid that.