find 命令不包含某文件夹的选项

输入

$ tree

输出

.
├── dist
├── index.css
├── index.html
├── index.js
└── node_modules

2 directories, 3 files

假设目录下存在index.html, index.css, index.js, node_modules 等文件或目录。

利用 find 命令找出当前目录下不包含node_moduels的文件或文件夹

输入

$ find . -maxdepth 1 -not -name node_moduels

输出

./dist
./index.css
./index.html
./index.js

利用 find 命令将目录下非node_modules的文件或目录复制到dist目录。

$ find . -maxdepth1 -not -name node_modules -not -name dist|xargs -J % cp -r % dist

查看结果

$ ls dist

输出

index.css	index.html	index.js
关于本文如您有任何想法和意见,欢迎与我们联系,邮箱地址zhi@uqugu.com
您对本文有什么看法,喜欢或者不喜欢都可以发表意见。