Monday, 23 December 2019
Wednesday, 18 December 2019
How to create a tar file in linux
create a tar file in linux systems
create a tar for all available file in directories
tar -cvf out_test.tar.z *
create a tar for specific file extension
tar -cvf out1_test.tar.z *.log
create a tar for multiple directory
tar -cvf out1_tar.z /home/oradev/out1 /home/oradev/out2
create compress tar file .gz(it will compress the file size)
tar -cvzf compress.tar.gz *.log
[oradev@erp2 out1]$ ls -lt
-rw-rw-r-- 1 oradev oradev 145 Dec 6 16:12 compress.tar.gz
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 16:00 out1_test.tar.z
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 15:58 out_test.tar.z
Another compress options available it slow compare previous one
tar cvfj compress3.tar.bz2 *.log
Untar commands:
Untar the files to current directory
tar -xvf out1_tar.z
tar -xvf compress.tar.gz
tar -xvf compress2.tar.bz2
Untar the files to remote directory
tar -xvf out_test.tar.z -C /home/oradev/out2/
tar -xvf compress.tar.gz -C /home/oradev/out2/
tar -xvf compress2.tar.bz2 -C /home/oradev/out2/
Untar specific file from tar file:
tar -xvf out1_tar.z test1.log
tar -zxvf compress.tar.gz test1.log
tar -jxvf compress2.tar.bz2 /home/oradev/test1.log
Untar multiple files from tar file.
tar -xvf out2.tar.z best1.log best2.log
tar -zxvf out2.tar.z best1.log best2.log
tar -jxvf out2.tar.z best1.log best2.log
Untar group of files :
tar -xvf out2.tar.z --wildcards '*.log'
tar -zxvf out2.tar.z --wildcards '*.log'
tar -jxvf out2.tar.z --wildcards '*.log'
Include the file or directories into the tar file:
tar -rvf out_tar.z out2
tar -rvf out_tar.z best1.log
Note : Its not possible for compress tar gz and bz2
To count the tar file size:
tar -czf - out23_tar.z |wc -l
tar -czf - out23_tar.gz |wc -l
tar -czf - out23_tar.bz2 |wc -l
Exclude the file from directory while create tar file.
tar -cvzf out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvf out23_tar.z /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvfj out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
List of available files in created tar file:
tar -tvf out1_tar.z
tar -tvf compress.tar.gz
tar -tvf compress.tar.gz
create a tar for all available file in directories
tar -cvf out_test.tar.z *
create a tar for specific file extension
tar -cvf out1_test.tar.z *.log
create a tar for multiple directory
tar -cvf out1_tar.z /home/oradev/out1 /home/oradev/out2
create compress tar file .gz(it will compress the file size)
tar -cvzf compress.tar.gz *.log
[oradev@erp2 out1]$ ls -lt
-rw-rw-r-- 1 oradev oradev 145 Dec 6 16:12 compress.tar.gz
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 16:00 out1_test.tar.z
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 15:58 out_test.tar.z
Another compress options available it slow compare previous one
tar cvfj compress3.tar.bz2 *.log
Untar commands:
Untar the files to current directory
tar -xvf out1_tar.z
tar -xvf compress.tar.gz
tar -xvf compress2.tar.bz2
Untar the files to remote directory
tar -xvf out_test.tar.z -C /home/oradev/out2/
tar -xvf compress.tar.gz -C /home/oradev/out2/
tar -xvf compress2.tar.bz2 -C /home/oradev/out2/
Untar specific file from tar file:
tar -xvf out1_tar.z test1.log
tar -zxvf compress.tar.gz test1.log
tar -jxvf compress2.tar.bz2 /home/oradev/test1.log
Untar multiple files from tar file.
tar -xvf out2.tar.z best1.log best2.log
tar -zxvf out2.tar.z best1.log best2.log
tar -jxvf out2.tar.z best1.log best2.log
Untar group of files :
tar -xvf out2.tar.z --wildcards '*.log'
tar -zxvf out2.tar.z --wildcards '*.log'
tar -jxvf out2.tar.z --wildcards '*.log'
Include the file or directories into the tar file:
tar -rvf out_tar.z out2
tar -rvf out_tar.z best1.log
Note : Its not possible for compress tar gz and bz2
To count the tar file size:
tar -czf - out23_tar.z |wc -l
tar -czf - out23_tar.gz |wc -l
tar -czf - out23_tar.bz2 |wc -l
Exclude the file from directory while create tar file.
tar -cvzf out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvf out23_tar.z /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvfj out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
List of available files in created tar file:
tar -tvf out1_tar.z
tar -tvf compress.tar.gz
tar -tvf compress.tar.gz
Friday, 6 December 2019
create a tar file
create a tar file in linux systems
create a tar for all available file in directories
tar -cvf out_test.tar.z *
create a tar for specific file extension
tar -cvf out1_test.tar.z *.log
create a tar for multiple directory
tar -cvf out1_tar.z /home/oradev/out1 /home/oradev/out2
create compress tar file .gz(it will compress the file size)
tar -cvzf compress.tar.gz *.log
[oradev@erp2 out1]$ ls -lt
-rw-rw-r-- 1 oradev oradev 145 Dec 6 16:12 compress.tar.gz
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 16:00 out1_test.tar.z
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 15:58 out_test.tar.z
Another compress options available it slow compare previous one
tar cvfj compress3.tar.bz2 *.log
Untar commands:
Untar the files to current directory
tar -xvf out1_tar.z
tar -xvf compress.tar.gz
tar -xvf compress2.tar.bz2
Untar the files to remote directory
tar -xvf out_test.tar.z -C /home/oradev/out2/
tar -xvf compress.tar.gz -C /home/oradev/out2/
tar -xvf compress2.tar.bz2 -C /home/oradev/out2/
Untar specific file from tar file:
tar -xvf out1_tar.z test1.log
tar -zxvf compress.tar.gz test1.log
tar -jxvf compress2.tar.bz2 /home/oradev/test1.log
Untar multiple files from tar file.
tar -xvf out2.tar.z best1.log best2.log
tar -zxvf out2.tar.z best1.log best2.log
tar -jxvf out2.tar.z best1.log best2.log
Untar group of files :
tar -xvf out2.tar.z --wildcards '*.log'
tar -zxvf out2.tar.z --wildcards '*.log'
tar -jxvf out2.tar.z --wildcards '*.log'
Include the file or directories into the tar file:
tar -rvf out_tar.z out2
tar -rvf out_tar.z best1.log
Note : Its not possible for compress tar gz and bz2
To count the tar file size:
tar -czf - out23_tar.z |wc -l
tar -czf - out23_tar.gz |wc -l
tar -czf - out23_tar.bz2 |wc -l
Exclude the file from directory while create tar file.
tar -cvzf out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvf out23_tar.z /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvfj out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
List of available files in created tar file:
tar -tvf out1_tar.z
tar -tvf compress.tar.gz
tar -tvf compress.tar.gz
create a tar for all available file in directories
tar -cvf out_test.tar.z *
create a tar for specific file extension
tar -cvf out1_test.tar.z *.log
create a tar for multiple directory
tar -cvf out1_tar.z /home/oradev/out1 /home/oradev/out2
create compress tar file .gz(it will compress the file size)
tar -cvzf compress.tar.gz *.log
[oradev@erp2 out1]$ ls -lt
-rw-rw-r-- 1 oradev oradev 145 Dec 6 16:12 compress.tar.gz
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 16:00 out1_test.tar.z
-rw-rw-r-- 1 oradev oradev 10240 Dec 6 15:58 out_test.tar.z
Another compress options available it slow compare previous one
tar cvfj compress3.tar.bz2 *.log
Untar commands:
Untar the files to current directory
tar -xvf out1_tar.z
tar -xvf compress.tar.gz
tar -xvf compress2.tar.bz2
Untar the files to remote directory
tar -xvf out_test.tar.z -C /home/oradev/out2/
tar -xvf compress.tar.gz -C /home/oradev/out2/
tar -xvf compress2.tar.bz2 -C /home/oradev/out2/
Untar specific file from tar file:
tar -xvf out1_tar.z test1.log
tar -zxvf compress.tar.gz test1.log
tar -jxvf compress2.tar.bz2 /home/oradev/test1.log
Untar multiple files from tar file.
tar -xvf out2.tar.z best1.log best2.log
tar -zxvf out2.tar.z best1.log best2.log
tar -jxvf out2.tar.z best1.log best2.log
Untar group of files :
tar -xvf out2.tar.z --wildcards '*.log'
tar -zxvf out2.tar.z --wildcards '*.log'
tar -jxvf out2.tar.z --wildcards '*.log'
Include the file or directories into the tar file:
tar -rvf out_tar.z out2
tar -rvf out_tar.z best1.log
Note : Its not possible for compress tar gz and bz2
To count the tar file size:
tar -czf - out23_tar.z |wc -l
tar -czf - out23_tar.gz |wc -l
tar -czf - out23_tar.bz2 |wc -l
Exclude the file from directory while create tar file.
tar -cvzf out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvf out23_tar.z /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
tar -cvfj out23_tar.gz /home/oradev/test --exclude=/home/oradev/old --exclude=/home/oradev/best
List of available files in created tar file:
tar -tvf out1_tar.z
tar -tvf compress.tar.gz
tar -tvf compress.tar.gz
Subscribe to:
Posts (Atom)