使用`cd path /&&&amp ;; zip -r name.zip目录/`

时间:2013-08-14 13:44:24

标签: linux command-line thread-safety command zip

我想压缩目录,但我需要使用完整路径,我需要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个命令)会不安全,&&是否足以使其线程安全?

1 个答案:

答案 0 :(得分:1)

command1 && command2意味着command2只有在command1退出且返回码为零时才会执行。如果/full/path/to/不存在,则不会执行zip命令。

关于线程安全性部分,如果您有多个进程尝试在给定目录中创建具有相同名称的文件,则可能会导致意外结果。