0

Searching whole system using:

find / -type f -size +100M -exec ls -lh {} \; | awk '{ print $9 "|| Size : " $5 }'

How can I omit a directory? I see -prune -o, but I am not sure how to format the option.

  • [so] is for programming questions, not questions about using or configuring Unix and its utilities. [unix.se] or [su] would be better places for questions like this. – Barmar Nov 23 '21 at 17:01
  • `find / -type d -name 'directory_to_omit' -prune -o -type f ...` – Barmar Nov 23 '21 at 17:02
  • [Don't use `ls` in scripts.](https://mywiki.wooledge.org/ParsingLs) If you really are on Linux, you want to use the `-printf` predicate of `find` to print out the fields you want. – tripleee Nov 23 '21 at 17:03

2 Answers2

0
find / -path /path/to/ommit -prune -o -type f -size +100M -exec ...
#      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
choroba
  • 231,213
  • 25
  • 204
  • 289
0

From man:

To ignore a whole directory tree, use -prune rather than checking every file in the tree. For example, to skip the directory src/emacs and all files and directories under it, and print the names of the other files found, do something like this: find . -path ./src/emacs -prune -o -print Note that the pattern match test applies to the whole file name, starting from one of the start points named on the command line.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134