2 added 33 characters in body
source | link

As an alternative, with GNU date, you can do:

eval "$(date -r "$file" +'year=%Y month=%-m day=%-d')"

To have the modification time's year, month and day component stored in $year, $month and $day respectively (as decimal integers, remove the -s in %-m and %-d if you care for the leading zeroszeros; see also %y for 2-digit years).

(note that contrary to GNU stat, for files of type symlink, the modification time of the target of the symlink is considered rather than that of the symlink itself. With GNU stat, you'd use stat -L).

As an alternative, with GNU date, you can do:

eval "$(date -r "$file" +'year=%Y month=%-m day=%-d')"

To have the modification time's year, month and day component stored in $year, $month and $day respectively (as decimal integers, remove the -s in %-m and %-d if you care for the leading zeros).

(note that contrary to GNU stat, for files of type symlink, the modification time of the target of the symlink is considered rather than that of the symlink itself. With GNU stat, you'd use stat -L).

As an alternative, with GNU date, you can do:

eval "$(date -r "$file" +'year=%Y month=%-m day=%-d')"

To have the modification time's year, month and day component stored in $year, $month and $day respectively (as decimal integers, remove the -s in %-m and %-d if you care for the leading zeros; see also %y for 2-digit years).

(note that contrary to GNU stat, for files of type symlink, the modification time of the target of the symlink is considered rather than that of the symlink itself. With GNU stat, you'd use stat -L).

1
source | link

As an alternative, with GNU date, you can do:

eval "$(date -r "$file" +'year=%Y month=%-m day=%-d')"

To have the modification time's year, month and day component stored in $year, $month and $day respectively (as decimal integers, remove the -s in %-m and %-d if you care for the leading zeros).

(note that contrary to GNU stat, for files of type symlink, the modification time of the target of the symlink is considered rather than that of the symlink itself. With GNU stat, you'd use stat -L).