Tuesday, July 18, 2006

Execute the "touch" command recursively

If you want to update the access time of a set of files, you can use
touch *

However, if you want to touch files and directories recursively, the touch command does not have a built in option. Instead use this command to achieve the same result:

If XXX is the dir within which you want to touch recursively, execute the foll. (Give the full path to XXX as needed)

find XXX | xargs touch


2 comments:

Anonymous said...

This doesn't work on sub folders and files that have spaces in the name. How do you get around that?

Anonymous said...

use find . -print0 | xargs -r0 touch