3

When I use touch with the -t option to change the modification time of a file, for example:

> touch -t 201702160701 ABC.script

Then the file that appeared as such before:

-rwxrwxrwx  1 timruss  staff    0 Oct 21 23:12 ABC.script

Will now appear as:

-rwxrwxrwx  1 timruss  staff    0 Feb 16  2017 ABC.script

Why is that?

  • 2
    What would you expect to happen? – nohillside Oct 22 '17 at 5:25
  • Touch can be used to set the time that you "say" you edited the file....... useful in discussions with the boss... not me : ever, honest... – Solar Mike Oct 22 '17 at 8:02
8

What you are seeing is the normal and expected behavior.

From the manual page for ls:

If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.

To see output including month, day, hour, minute, second, and year on files that fall into the category above, use the -T option.

-T When used with the -l (lowercase letter “ell”) option, display complete time information for the file, including month, day, hour, minute, second, and year.

Example:

ls -lT ABC.script
-rwxrwxrwx  1 timruss  staff    0 Feb 16 07:01:00 2017 ABC.script
  • Yes, that is what the manual page says. That said, Even when I provide a date within the 6 months window, I see the same behavior. for example: -rwxrwxrwx 1 timruss staff 0 Oct 25 2017 ABC.script – Shaun Dashjian Oct 23 '17 at 2:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .