Issue
I have the requirement to archive multiple files keeping the original files using tar and gzip. I cannot take risks with the files I have.
For example, the files to be archived are:
ls
1.doc
2.doc
3.doc
4.xls
5.xls
6.xls
The expected output:
ls
1.doc
2.doc
3.doc
4.xls
5.xls
6.xls
archive.tar.gz
Where archive.tar.gz
file contains all the doc and xls files.
Solution
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
Answered By - Adagyo Answer Checked By - Dawn Plyler (WPSolving Volunteer)