Did you try the command:
tar czf archive.tar.gz *.doc *.xls
Options here are:
- c: Create
- z: Gzip
- f: Output file
To extract:
tar xzf archive.tar.gz
You can read the manual of the tar command for advanced options:
man tar
Answer from Adagyo on Stack OverflowHow do I extract files from a tarball?
What is the difference between a tarball and a ZIP file?
What is the file extension of a tarball?
You can just use
tar -cf myfile.tar /etc/dir1 /var/www/html /home/somedir
also, you could use
tar -czf myfile.tar.gz /etc/dir1 /var/www/html /home/somedir
This second example (note the z in the -czf parameter) will compress the tar file using g(z)ip.
This works for me small change by adding "change to directory DIR (C)" argument
tar -zcvf myfile.tar -C /etc/dir1 /var/www/html /home/somedir
Take a look at the --new-volume-script option, which lets you replace the prompting mechanism with a different mechanism or with a generated filename. ((tar.info)Multi-Volume Archives in the tar info page.) The problem with split is that you need to cat the pieces back together to do anything, whereas a multivolume archive should be a bit more flexible.
You can use split for this:
tar czpvf - /path/to/archive | split -d -b 100M - tardisk
This tells tar to send the data to stdout, and split to pick it from stdin - additionally using a numeric suffix (-d), a chunk size (-b) of 100M and using 'tardisk' as the base for the resulting filenames (tardisk00, tardisk01, tardisk02, etc.).
To extract the data afterwards you can use this:
cat tardisk* | tar xzpvf -