jco*_*lum 6 tar directory-structure
文件夹结构:
\n\netc (dir)\ndeploy (dir)\nsrc (dir)\nconfig (dir)\ndist\n \xe2\x94\x9c- config (dir) \n \xe2\x94\x9c- index.js\n
Run Code Online (Sandbox Code Playgroud)\n\n我想要做的是将除根配置文件夹之外的所有内容打包并将其放在 .tar 文件中deploy
。dist/config
该文件夹出现在输出中非常重要。开始于:
tar -czf deploy/deploy.gz --exclude=deploy --exclude="./config/" ./*\n\n$ l ./deploy/deploy0/dist \nindex.js\nrouter.js\ntest\n
Run Code Online (Sandbox Code Playgroud)\n\n但这会导致缺失dist/config
。我能过来的唯一方法dist/config
是如果我不尝试排除任何名为 config 的内容:
tar -czf deploy/deploy.gz --exclude=deploy ./*\n\n$ l ./deploy/deploy1/dist \nconfig\nindex.js\nrouter.js\ntest\n
Run Code Online (Sandbox Code Playgroud)\n\nOSX 和 CentOS(开发和构建)。tar的 man让我认为这是不可能的。
\n\n我通过删除不需要的文件夹来解决这个问题,因为这是在构建环境中并且文件是一次性的。
\n你可以用来find
创建你的论点 - 虽然有点长:
find -mindepth 1 ! -wholename './config' ! -wholename './config/*'
Run Code Online (Sandbox Code Playgroud)
mindepth 1
排除.
,以及wholename
目录本身及其内容的两个排除。
tar -xzf deploy/deploy.gz --exclude="deploy" \
$( find -mindepth 1 ! -wholename './config' ! -wholename './config/*' )
Run Code Online (Sandbox Code Playgroud)