Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash update file modified date

I would like to make a shell script that updates the modified date on a directory and files. This is because I have realised that when you download a file it has the date from when it was uploaded. For example when I downloaded the cvim plugin for vim the date was 15 Dec 2008. I would like a script that will change that date to the current time.

Thanks

like image 889
iProgram Avatar asked Nov 25 '25 18:11

iProgram


1 Answers

Just use

touch file

to update the last modified time stamp. If your downloader can write to stdout this is even simpler:

downloader http://someURL > file

because a newly created (or replaced) file has always the current time as the last modified time.

For directories, you can create and remove a dummy file to update its last modified time stamp:

touch dummy; rm dummy

But everyone else on this planet doesn't care for directory timestamps. Why do you? :-)

like image 73
Jens Avatar answered Nov 27 '25 09:11

Jens