Category Archives: tar

TAR Commands

This should go into the Linux_common.ksh library file


tar -cvf /oracle/admin/scripts/mrc/apex_common_09062017.tar /oracle/admin/scripts/apex/*.ksh

tar –help

tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.

On Linux using -cvf will
c = create a tar
v = verbosely list the files
f = use archive file

The tar command allows creating a .tar file that can be gziped for easier transmit and smaller size

To pull a file from the archive you can use this

tar xzf archive.tar.gz my/path/to/file.txt

To list the files in the archive
tar tzf archive.tar.gz

t = list
z = zipped
v = verbose (if you include this you will see the dates of the files)
f = file archive

tar does not support “in-place” updating of files. However, you can add files to the end of an archive, even if they have the same path as a file already in the archive. In that case, both copies of the file will be in the archive, and the file added later will override the earlier one. The command to use for this is tar r (or tar u to only add files that are newer than the archive) is the command to use. The . in the path should not be a problem.

There is a catch, though: you can’t add to a compressed archive. So you would have to do:

Unzip the tar
gunzip archive.tar.gz

add to the tar file once it is unzipped
tar rf archive.tar data/data/com.myapp.backup/./files/settings.txt

rezip the tar file
gzip archive.tar

add to the mrc_10192017.tar file unzipped
tar -rvf mrc_10192017.tar /oracle/admin/scripts/mrc/nc1xtxsb03