我想要的只是愚蠢、简单的事情。ZIP 给定目录的所有内容。
\n\n我得到的结果是:
\n\nzip -r /home/andi/MEDIA_DUMPS/xyz_media.zip /home/andi/xyz/mega_backend/mega_www/media\nRun Code Online (Sandbox Code Playgroud)\n\n如下:
\n\n\xe2\x9e\x9c home tree -L 5\n.\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 andi\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 xyz\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 mega_backend\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 mega_www\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 media\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 csv\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 editor\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 img\nRun Code Online (Sandbox Code Playgroud)\n\n虽然我想要的只是这个:
\n\n\xe2\x9e\x9c media tree -L 1\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 csv\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 editor\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 img\nRun Code Online (Sandbox Code Playgroud)\n\n我使用 Tar 的临时方法:
\n\ntar -cjf /home/andi/MEDIA_DUMPS/xyz_media.tar.gz -C /home/andi/xyz/mega_backend/mega_www/media .\nRun Code Online (Sandbox Code Playgroud)\n\n\n
使用-j(垃圾路径)选项。
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not
store directory names. By default, zip will store the full path
(relative to the current directory).
Run Code Online (Sandbox Code Playgroud)
...
您可能想要制作一个包含 foo 中的文件的 zip 存档,而不记录目录名称 foo。
您可以使用 -j 选项来省略路径,如下所示:
zip -j foo foo/*