如何在不保留目录结构的情况下压缩目录? [英] How do I tar a directory without retaining the directory structure?
本文介绍了如何在不保留目录结构的情况下压缩目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个备份脚本,并且想要压缩文件目录:
I'm working on a backup script and want to tar up a file directory:
tar czf ~/backup.tgz /home/username/drupal/sites/default/files
这可以压缩它,但是当我解压生成的文件时,它包括完整的文件结构:这些文件位于home/username/drupal/sites/default/files
中.
This tars it up, but when I untar the resulting file, it includes the full file structure: the files are in home/username/drupal/sites/default/files
.
是否可以排除父目录,以便生成的tar只知道最后一个目录(files
)?
Is there a way to exclude the parent directories, so that the resulting tar just knows about the last directory (files
)?
推荐答案
cd /home/username/drupal/sites/default/files
tar czf ~/backup.tgz *
这篇关于如何在不保留目录结构的情况下压缩目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文