Quote:
Originally Posted by penquin.toes
While in /home/user1, create a new tar file which contains the entire contents of your current directory. Name the new tar file: user1.tar Have the new tar file created in your current directory. When you create the tar file, create it so that the extraction path will be the current directory.
|
In addition to what dunne wrote, you can take advantage of the advanced features of tar. You can use --exclude to not tar the existing tarball, for example.
Code:
tar cf user1.tar --exclude=user1.tar /home/user1/
tar tf user1.tar
Note that the --exclude has to come after the cf clause.
An even more advanced feature --transform allows you to use a
sed-like pattern to find and replace parts of the file name and path.
Code:
tar -c --transform='s#home/user1/#./#' -f user1.tar --exclude=user1.tar /home/user1/;
tar -tf user1.tar
Mentioning sed, though, may be pushing you off the edge into the deep end on your second day because it drags regular expressions into the question. Regular expressions are definitely worth learning and the time invested will pay for itself in short order. The 30-second explanation is s#old#new# substitutes the string 'old' for the string new 'new'
By the way you can compress the tarball with the z, j, or J options.
Code:
tar zcf user1.tar.gz --exclude=user1.tar.gz /home/user1/
tar ztf user1.tar.gz
z is for gzip, it is common. j is for bzip2 and J for xz. All, and more, are in the detailed manual page, which hopefully gets less confusing over time.
The manual pages are quite useful references but do vary in quality from program to program. It's useful to pick through them for useful options and ignore the rest until next time.