Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I need to pick up files older than 5 days and then do something (move them, actually).
This works fine with the find command. However i do NOT want to look in the subdirectories - how can i prevent the find command from looking there?
If that is impossible, is there an alternative approach???
Thanx

try 'man find'
take a look at the 'maxdepth' option. Looks to me like that is what you are looking for.

Arne:
If you don't have maxdepth, try this:
# find all on one line
find . -type f|awk ' gsub("^./","") '|egrep -v "/"provided you execute find in the current directory, find returns files in the form:
./directorypath/filename
./fileinherePipe the find command to awk to rid yourself of the beginning ./ and pipe that to egrep to eliminate anything that has a directory / in it.
This is terribly inefficient because find still is forced to check the directory structure. If you use Solaris, use nawk instead of awk.
Maybe somebody smarter than 1 can come up with a better idea.
Regards,
Nails
Also something like:find /tmp -type f .....
for obvious reasons.
Regards,
Nails

Thank you, this is indeed an alternative, especially since the underlying directory structure is rather limited.
But... Using find seems a bit heavy for the task... Would there be alternatives where the find command is not used altogether?
E.g., can we process the timestamp of a file directly as a date, say, after an ls? In that case we would not need the -m option of the find command.
thanx for your help.

Well, if directories never have an extension and files always do:
find ./*.* -mtime +5
That's a bit of an assumption though.
The -prune option has always looked promising but I could never figure out from the man pages exactly what it does.

hm. Prune is not supported in bash (or do i miss something here) and find ./*.* still doesnt seem to work in bash either?
bash-2.03$ find ./ -type f -mtime -1 -print
./rd/found
bash-2.03$ find ./*.* -type f -mtime -1 -print
find: cannot open ./*.*: No such file or directory(even though a file was in there)
thanx

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |