How do I tar a directory without retaining the directory structure?

前端 未结 9 1313
[愿得一人]
[愿得一人] 2020-12-23 16:01

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

This ta

相关标签:
9条回答
  • 2020-12-23 16:25

    To gunzip all txt (*.txt) files from /home/myuser/workspace/zip_from/ to /home/myuser/workspace/zip_to/ without directory structure of source files use following command:

    tar -P -cvzf /home/myuser/workspace/zip_to/mydoc.tar.gz  --directory="/home/myuser/workspace/zip_from/" *.txt
    
    0 讨论(0)
  • 2020-12-23 16:32

    Hi I've a better solution when enter in the specified directory it's impossible (Makefiles,etc)

    tar -cjvf files.tar.bz2 -C directory/contents/to/be/compressed .
    

    Do not forget the dot (.) at the end !!

    0 讨论(0)
  • 2020-12-23 16:36
    tar -Cczf ~/backup.tgz /home/username/drupal/sites/default/files
    

    -C does the cd for you

    0 讨论(0)
提交回复
热议问题