Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Extract CTIME in zsh 4.2.3?




>     In fact, it is not present in SUS. Probably it is present only
> for a few filesystems, so it has to be retrieved in a non-portable
> way. Under Linux, I don't recall now of any filesystem that
> implements creation time for entries. It's not an operating system
> problem, is a filesystem problem. Even in the case you can write
> code for some UNIX flavour to retrieve that data, it will only work
> for some particular filesystem. The VFS on top of that will only
> store the st_atime, st_mtime and st_ctime values in the metadata.

actually GNU/linux is definitely the only unix-like OS where you are likely to
be unable to retrieve a file's ctime.

"stat -f %c FILE" should be portable on any BSD os, including macosx and
probably on any solaris distribution as well.

you will need to use the "date" command in order to format the date as stat will
return a timestamp. each system is likely to implement shorthands to retrieve
the date in human readable form but in a less likely portable way.

the shell you are using will probably make no difference as stat is usually
either not a builtin or is system-dependant, but you can use `which stat` if you
want to make sure the builtin will not be used.

this is very sad, and i'd like to make clear i'm not looking forwards to start a
flame war, but if you are running linux trying to make something portable, you
probably should forget about using the shell, and switch to something like perl.
on the other hand ls + sed is more than likely to be portable under any OS, but
what you will retrieve in linux will probably not be the actual ctime of the file



Messages sorted by: Reverse Date, Date, Thread, Author