我想压缩目录,但我需要使用完整路径,我需要zip文件从目录开始,而不是/
。
这个问题在这里解决了:Command to zip a directory using a specific directory as the root
答案基本上是使用这个:
如果我想在名为myFile.zip的文件中压缩full/path/to/directory/
,我需要使用命令
cd /full/path/to/ && zip -r myFile.zip directory/
现在,我的问题是:这线程安全吗?没有&&
(2个命令)会不安全,&&
是否足以使其线程安全?
答案 0 :(得分:1)
说command1 && command2
意味着command2
只有在command1
退出且返回码为零时才会执行。如果/full/path/to/
不存在,则不会执行zip
命令。
关于线程安全性部分,如果您有多个进程尝试在给定目录中创建具有相同名称的文件,则可能会导致意外结果。