LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   find command and multiple * usage (https://www.linuxquestions.org/questions/linux-general-1/find-command-and-multiple-%2A-usage-4175486674/)

postcd 12-03-2013 06:03 AM

find command and multiple * usage
 
Please can i use:

find /home/username/public_html/_sub/*/wp-content/*cache* -type f -delete

command to empty all folders contianing "cache" in wp-content directory.

issue is that in /home/username/public_html/_sub/
i have around 50 folders and i want to use this rule on all of them, so im using *.

im asking there because im afraid could delete whole /_sub contents or similar horror story

i just want to empty folders containing cache in that wp-content directories

i cant say it my english is bad

is above command safe?

bonnydeal 12-03-2013 06:19 AM

You could always check it by printing what files are found (and hence what would be deleted):

Code:

find /home/username/public_html/_sub/*/wp-content/*cache* -type f -print

JJJCR 12-03-2013 04:54 PM

you can check this one, you can use cp or mv to make sure there is no disaster rather than deletion

find . -type f -name "some*.fil" -exec cp -iv {} /destination/folder \;
# or less likely...
find . -type f -name "some*.fil" -print0 | xargs -J % cp -iv /destination %

got that from this link: http://www.daemonforums.org/showthread.php?t=6029


All times are GMT -5. The time now is 06:39 PM.