Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Exclude directories with <code>-prune</code> option:</p> <pre><code>find . -type d -name ProductA -prune -o -type d -exec chmod 755 {} \; </code></pre> <p>It tells: if file is a directory and has name <code>ProductA</code>, then do not descend into it (<code>-prune</code>), else (<code>-o</code> means or) if file is a directory, then execute the <code>chmod 755</code> on it.</p> <p><code>find</code> expressions are made of options, tests (can be false or true) and actions, separated by operators. When no action is given, then <code>-print</code> action is performed on all files for which the expression is true. <code>-exec</code> is an action, <code>-prune</code> is another. You can chain multiple actions with <code>-a</code> and <code>-o</code>. <code>expr1 -a expr2</code> will execute both actions, whereas <code>expr1 -o expr2</code> will execute <code>expr2</code> only if <code>expr1</code> evaluates to false.</p> <p>So if you want to exclude multiple directories, you can write</p> <pre><code>find . -type d -name ProductA -prune -o -type d -name ProductC -prune -o -type d -exec chmod 755 {} \; find . -type d -name ProductA -prune -o -type d -name ProductC -prune -o -type f -exec chmod 644 {} \; </code></pre> <p>or just:</p> <pre><code>find . -type d -name "Product[AC]" -prune -o -type d -exec chmod 755 {} \; find . -type d -name "Product[AC]" -prune -o -type f -exec chmod 644 {} \; </code></pre> <p>and you can combine them too:</p> <pre><code>find . -type d -name "Product[AC]" -prune -o -type d -exec chmod 755 {} \; -o -type f -exec chmod 644 {} \; </code></pre> <p>If you have a more complex directory structure, say you want to exclude <code>ProductA/data</code> but not <code>ProductB/data</code> nor <code>ProductA/images</code>, then you can use the <code>-path</code> test:</p> <pre><code>find . -path ./ProductA/src -prune -o -print </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload