Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    find command and multiple * usage


    Please can i use:

    Code:
    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?

  2. #2
    do the files themselves have cache in the name, or is it dirs, too? assuming it is files only, try:

    Code:
    find /home/username/public_html/_sub/*/wp-content/ -type f -name '*cache*' -exec echo rm -vf {}  \;
    that command is safe to run as is, b/c it just echoes the "rm" command, it does not actually run it. if you like what you see, then just remove the "echo" from the command, e.g.:

    Code:
    find /home/username/public_html/_sub/*/wp-content/ -type f -name '*cache*' -exec /bin/rm -vf {}  \;
    if you want to be prompted before removing the files, replace the "-f" (force) with "-i" (interactive), e.g.:

    Code:
    find /home/username/public_html/_sub/*/wp-content/ -type f -name '*cache*' -exec /bin/rm -vi {}  \;

  3. #3
    thank you, the cache in folder name only.
    i found its beneficial to remove -delete operator and instead add -print or no operator at all and it will list the matching files, so then im sure what it will delete..

  4. $spacer_open
    $spacer_close
  5. #4
    Quote Originally Posted by postcd View Post
    thank you, the cache in folder name only.
    in that case you could try something like

    Code:
    find . -type f -path '*cache*' ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •