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

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


Use the --directory option:

 tar czf ~/backup.tgz --directory=/home/username/drupal/sites/default files 


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 !!


cd /home/username/drupal/sites/default/filestar czf ~/backup.tgz *