[ Table Of Contents ][ Answer Guy Current Index ] greetings   1   2   3   4   5   6   7   8   9   10   11   12 [ Index of Past Answers ]


(?) The Answer Gang (!)


By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and the Gang, the Editors of Linux Gazette... and You!
Send questions (or interesting answers) to linux-questions-only@ssc.com

There is no guarantee that your questions here will ever be answered. You can be published anonymously - just let us know!


(?) touch files recursively linux mandrake 7.2

From Martin Colello

Answered By Ben Okopnik

This is probably so easy as to be considered a joke, but I can't figure out how to do it.

I need to touch a bunch of directories recursively. All the directories and their contents, but I can't find any option in the touch command that allows this.

Any help appreciated, thanks!

(!) [Ben] I've never seen a 'recurse' option in any "touch" I've used. Doesn't mean that one doesn't exist, though. Since yours doesn't, try this:
find DIR -exec touch {} \;
where DIR is either the path to the top directory that contains all the subdirectories you want to touch, OR is a list of the paths to those subdirectories themselves. One of those two options should do what you want. If you want to touch only the files (not the directories), add the '-type f' option before '-exec'.
It can also be a healthy idea to try it with "echo" instead of "touch" the first time; I test a lot of my "dangerous" scripts that way before letting them loose on live data.
(!) [Mike] Or:
find DIR | xargs touch

(?) Hi, just wanted to let you know the command worked great, I never thought of using any other argument with find except -name.

(!) [Ben] "find" is a very cool utility. The man page is pretty big, but it's well worth reading up on. Lots and lots of good options.

(?) Linux Gazette rocks, thanks a lot for your help.

(!) [Ben] Yeah, we know. :)
You're welcome!

(?) Just out of curiosity, the reason I needed to touch everything was because my anonymous ftp server wouldn't show certain files even though the permissions were the same as others that worked. But I found if I touched one then it showed up. Now they all show up thanks to you, by why should this have happened in the first place?

(!) [Ben] I haven't experienced any problems with setting up FTP servers, so I can't really comment.
(!) [Heather] Readers, if you think you know what it might have been, let us know. You can reach The Answer Gang as linux-questions-only@ssc.com.


This page edited and maintained by the Editors of Linux Gazette Copyright © 2001
Published in issue 66 of Linux Gazette May 2001
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/


[ Table Of Contents ][ Answer Guy Current Index ] greetings   1   2   3   4   5   6   7   8   9   1   1   1 [ Index of Past Answers ]