我所在的目录包含:
f0 f1 f2 .h1 .h2 .h3 / tmp
我想压缩所有文件并清除原始文件。我不想tar / tmp,也不想触摸其文件。在https://unix.stackexchange.com/questions/24870/tar-files-only-no-directories之后,看来没有直接的方法可以执行此操作,因此我尝试了以下操作:
find . -maxdepth 1 -type f -exec tar cvf test.tar {} --remove-files \;
几乎可以使用:
-存档已创建
-所有文件都被删除
-/ tmp保持不变
但是
我的存档中只有文件f2(!)
尽管如此,我还是找到了一个非常棘手的解决方案:
find . -maxdepth 1 -type f -exec tar cvf test.tar {} \; && find . -maxdepth 1 -type f ! -name '*.tar' -exec shred -xuvz {} \;
但是更优雅的东西将不胜感激。
感谢乡亲!