cp
默认情况下显示所有正在复制的文件的列表。我正在使用命令:
sudo cp -r $WORKSPACE/DMS/dist/conf/* $WORKSPACE/DMS/NewWar/NewFiles/conf
这将显示正在复制的文件的完整长列表,如下所示:
+ sudo cp -r /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/XmlSchema-1.3.1.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/XmlSchema-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/activation-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/annogen-0.1.0.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/annogen-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/antlr.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/avalon-framework-4.1.3.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-api-1.2.4.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-api-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-dom-1.2.4.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-dom-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-impl-1.2.4.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axiom-impl-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axis.jar /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/axis2-LICENSE.txt /var/lib/jenkins/workspace/6.5.10/DMS/OldBase/dist/sharedlib/backport-util-concurrent-2.2.jar
... 而这样的例子不胜枚举。在这种情况下如何静默复制文件?
答案1
如果您必须set -x
在脚本的其余部分使用但不想在命令中看到它,cp
只需在您之前将其关闭cp
,然后再打开即可。
脚本:
#!/bin/bash
set -x
...
set +x
sudo cp -r "$WORKSPACE/DMS/dist/conf/"* "$WORKSPACE/DMS/NewWar/NewFiles/conf"
set -x
...
请注意,您不应sudo
在脚本中使用,并且应引用所有变量。