删除除一个目录中的内容之外的所

时间:2013-07-30 09:47:14

标签: macos

rm -rf ~/.jenkins/jobs/getfromgit/workspace/gitcheckoutdir

删除目录

下的所有内容
~/.jenkins/jobs/getfromgit/workspace/gitcheckoutdir

如何删除目录下的所有内容:

~/.jenkins/jobs/getfromgit/workspace/

目录除外:

~/.jenkins/jobs/getfromgit/workspace/gitcheckoutdir

1 个答案:

答案 0 :(得分:2)

最好的方法是首先移动gitcheckoutdir(1),删除工作区的内容(2),然后移回gitcheckoutdir(3);它会给:

(1)

$ mv ~/.jenkins/jobs/getfromgit/workspace/gitcheckoutdir ~/.jenkins/

(2)

$ rm -rf ~/.jenkins/jobs/getfromgit/workspace/* 

(3)

$ mv ~/.jenkins/gitcheckoutdir ~/.jenkins/jobs/getfromgit/workspace/