trouble with find
find . -atime +360 -exec ls -lah {} \;
that works fine, but i have a directory .snapshot that is a major waste of time to traverse through. i want find to exclude it. there is an option of -prune but i cannot seem to get it to work without saying paths must precede expression did some searching but cannot find example of -prune on the net any ideas? i was able to use ! -name .snapshot to avoid the directory, but this still does not address the issue of how to use -prune effectively. |
Prune is a odd function of sometimes annoying utility... try these to get an idea, be ultra careful using it with exec and -print as they DONT ACT THE SAME. Always test and test and test and test...
Code:
rweaver@core:~/test$ cat demo.sh |
Quote:
|
…-path ! '*.snapshot*'… ?
|
I believe the example in post #4 will still transverse the files in the .snapshot directory, even though the files in it will not be printed. Using prune, the directory will not be traversed, saving time if there are many files in the pruned directory. The find man page even says "To ignore a whole directory tree, use -prune..." in the paragraph describing -path.
|
you could make it more of a bash script
Code:
#!/usr/bin/bash |
Quote:
If .snapshot was not so large, it would not be a big deal and this script would apply. As read this script would only parse out .snapshot/* after find has traversed it. In the environment I work with .snapshot contains at least 4 exact copies of the data set where it exists. They are time delayed local archives. So to traverse .snapshot would cause for at least 4 times the amount of files required for the desired results. |
Did my reply and examples tell you what you needed to know about how to use prune or do you need additional information?
|
Quote:
|
All times are GMT -5. The time now is 06:10 PM. |