How to exclude a directory in find . command

后端 未结 30 1363
醉酒成梦
醉酒成梦 2020-11-22 03:36

I\'m trying to run a find command for all JavaScript files, but how do I exclude a specific directory?

Here is the find code we\'re using.<

30条回答
  •  既然无缘
    2020-11-22 04:09

    For a working solution (tested on Ubuntu 12.04 (Precise Pangolin))...

    find ! -path "dir1" -iname "*.mp3"
    

    will search for MP3 files in the current folder and subfolders except in dir1 subfolder.

    Use:

    find ! -path "dir1" ! -path "dir2" -iname "*.mp3"
    

    ...to exclude dir1 AND dir2

提交回复
热议问题