On 26/12/2020 13:06, Jeffrey Walton wrote:
Hi Everyone,I'm trying to restore filetimes based on the timestamp from a ZIP file. I can extract the newest filetime from a ZIP with: unzip -l "${file}" 2>&1 | head -n -3 | tail -n +4 | cut -b 12-27 | sort -r | uniq | head -n 1 (The head and tail trims away header and footer cruft so only date/time's remain). That yields a date/time like: 12-31-1998 23:07 When I plug it into 'touch' it results in: Setting /var/www/html/crypto30.zip to 12-31-1998 23:07 touch: invalid date format ‘12-31-1998 23:07’ Is there some way to get touch to accept the date/time from the ZIP archive?
Supported input formats are documented at: https://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html In summary, if you're specifying numeric calendar items with dashes, the order needs to be YY-MM-DD So you could pipe through something like: sed 's/\([^-]*-[^-]*\)-\(....\)/\2-\1/' cheers, Pádraig
