Why does touch -t replace the modification time with the year when I ls?
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