Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clarity on depth flags when using find and move 1

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary user)

I have tried making a script that looks for directories older than 24 hours at 'top' level; by that I mean I do not want it to descend into subfolders) it should then move (using a special move binary) the found directories to another location and place them in a folder with the date from yesterday.

Here is my script:
#!/bin/sh
#
cd /path/to/my/folder/to/search/in
#
YESTERDAY=$(date -d "yesterday" '+%Y-%m-%d')
#
find . -maxdepth 1 -mindepth 1 -mtime 1 -type d -exec /usr/etc/appletalk/ksmv {} /target/path/after/moving/$YESTERDAY/ \;

Can anyone confirm, have I understood the flags correctly?

Best regards
 
My guess would be you don't need the mindepth if you're only searching the top-level directory. mindepth only seems appropriate with maxdepth, when searching between two levels. never having used it, this might be wrong!

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top