Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

linux - 如何在find中排除目录。命令(How to exclude a directory in find . command)

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

(我正在尝试为所有JavaScript文件运行find命令,但是如何排除特定目录?)

Here is the find code we're using.

(这是我们正在使用的find代码。)

for file in $(find . -name '*.js')
do 
  java -jar config/yuicompressor-2.4.2.jar --type js $file -o $file
done
  ask by helion3 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If -prune doesn't work for you, this will:

(如果-prune不适合您,这将:)

find -name "*.js" -not -path "./directory/*"

Caveat: requires traversing all of the unwanted directories.

(警告:需要遍历所有不需要的目录。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...