Few years ago, during my undergraduate degree, I was asked to compress my assignment using tar and submit it. I was so scared with all the tar+compress+unix jig, that I ended up NOT submitting the assignment :O. Now when I look back, I feel so stupid. Anyways, now that I know a lil bit more about tar and untar, I’d like to share my knowledge with everyone and hopefully help someone from NOT submitting an assignment
Basically tar can be used to group multiple files/directories into one single file, and separate(extract) an archive created by tar into separate files.
* To group multiple files : tar -cvf foo.tar a.dat b.dat c.dat ( this will group files [a-c]*.dat to one file foo.tar )
c = create a tar file
v = verbose( nothing important )
f = create the tar file with filename provided as the argument
Thats all you need to know to tar(group) a bunch of files/directories.
* To tar files and gzip them : tar -czf foo.tar.gz *.dat ( this will create a gzip-compressed Tar file of the name foo.tar.gz of all files with a .dat suffix in that directory )
* To untar(separate) files from a tar archive : tar -xvf foo.tar ( this will produce three separate files a.dat, b.dat and c.dat )
* To untar(extract) a gzipped tar archive file : tar -xzf foo.tar.gz
* To untar a bzipped (.bz2) tar archive file : tar -xjf foo.tar.bz2