1

This is tar's output when listing files in a tarball:

> tar zvtf my.tar.gz
-rw-rw-r-- myuser/mygroup  2363 2018-05-03 15:45 test.txt

Is there any way to customize the date format to print out high-res epoch seconds, like "1537492797.82289"?

The version of tar is:

> tar --version
tar (GNU tar) 1.23
1

No, there isn't any, at least not with gnu tar.

Here is how the date is formatted (tartime() in tree/src/list.c)

if (tm)
  {
    if (full_time)
        {
        strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M:%S", tm);
        code_ns_fraction (ns, buffer + strlen (buffer));
        }
    else
        strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M", tm);
    return buffer;
  }

And here is how the file header is printed (simple_print_header() in tree/src/list.c):

fprintf (stdlis, "%s %s/%s %*s %-*s",
         modes, user, group, ugswidth - pad + sizelen, size,
         datewidth, time_stamp);
  • Thank you for backing up your answer with the tar source. – Elle Fie Oct 2 '18 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.