
Terminal - Commands using tar - 170 results
ssh user@<source_host> -- tar cz <path> | ssh user@<destination_host> -- tar vxzC <path>
This is sample output - yours may be different.
This is a 'nocd' alternative :)
tar pcf - home | pv -s $(du -sb home | awk '{print $1}') --rate-limit 500k | gzip > /mnt/c/home.tar.gz
This is sample output - yours may be different.
7.85GB 0:20:27 [6.54MB/s] [=========================================================================>] 100%
tar directory and compress it with showing progress and Disk IO limits. Pipe Viewer can be used to view the progress of the task, Besides, he can limit the disk IO, especially useful for running Servers.
ls | while read filename; do tar -czvf "$filename".tar.gz "$filename"; rm "$filename"; done
This is sample output - yours may be different.
Compresses each file individually, creating a $fileneame.tar.gz and removes the uncompressed version, usefull if you have lots of files and don't want 1 huge archive containing them all. you could replace ls with ls *.pdf to just perform the action on pdfs for example.
ssh user@host "cat /path/to/backup/backupfile.tar.bz2" |tar jpxf -
This is sample output - yours may be different.
Here how to recover the remote backup over ssh
tar jcpf - [sourceDirs] |ssh user@host "cat > /path/to/backup/backupfile.tar.bz2"
This is sample output - yours may be different.
Execute it from the source host, where the source files you wish backup resides. With the minus '-' the tar command deliver the compressed output to the standar output and, trough over the ssh session to the remote host. On the other hand the backup host will be receive the stream and read it from the standar input sending it to the /path/to/backup/backupfile.tar.bz2
Server: nc -l 1234 |tar xvfpz - ;Client: tar zcfp - /path/to/dir | nc localhost 1234
This is sample output - yours may be different.
Create a tarball on the client and send it across the network with netcat on port 1234 where its extracted on the server in the current directory.
ssh -c 'tar cvzf - -C /path/to/src/*' | tar xzf -
This is sample output - yours may be different.
Create tarball on stdout which is piped to tar reading from stdin all over ssh
wget -qO - http://example.com/path/to/blah.tar.gz | tar xzf -
This is sample output - yours may be different.
tar -zcvpf backup_`date +"%Y%m%d_%H%M%S"`.tar.gz `find <target> -atime +5 -type f` 2> /dev/null | parallel -X rm -f
This is sample output - yours may be different.
This deals nicely with files having special characters in the file name (space ' or ").
Parallel is from https://savannah.nongnu.org/projects/parallel/
svn st | cut -c 9- | parallel -X tar -czvf ../backup.tgz
This is sample output - yours may be different.
xargs deals badly with special characters (such as space, ' and "). In this case if you have a file called '12" record'.
Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.
Both solutions work bad if the number of files is more than the allowed line length of the shell.
tar -tf <file.tar.gz> | parallel rm
This is sample output - yours may be different.
xargs deals badly with special characters (such as space, ' and "). To see the problem try this:
touch important_file
touch 'not important_file'
ls not* | xargs rm
Parallel https://savannah.nongnu.org/projects/parallel/ does not have this problem.
tar --exclude-vcs -cf src.tar src/
This is sample output - yours may be different.
~$ tar --version
tar (GNU tar) 1.20
dir='path to file'; tar cpf - "$dir" | pv -s $(du -sb "$dir" | awk '{print $1}') | tar xpf - -C /other/path
This is sample output - yours may be different.
7MB 0:00:01 [59.7MB/s] [============> ] 57% ETA 0:00:00
This may seem like a long command, but it is great for making sure all file permissions are kept in tact. What it is doing is streaming the files in a sub-shell and then untarring them in the target directory. Please note that the -z command should not be used for local files and no perfomance increase will be visible as overhead processing (CPU) will be evident, and will slow down the copy.
You also may keep simple with, but you don't have the progress info:
cp -rpf /some/directory /other/path
file='path to file'; tar -cf - "$file" | pv -s $(du -sb "$file" | awk '{print $1}') | gzip -c | ssh -c blowfish user@host tar -zxf - -C /opt/games
This is sample output - yours may be different.
112MB 0:00:12 [8.78MB/s] [==============> ] 96%
wtzc () { wget "$@"; foo=`echo "$@" | sed 's:.*/::'`; tar xzvf $foo; blah=`echo $foo | sed 's:,*/::'`; bar=`echo $blah | sed -e 's/\(.*\)\..*/\1/' -e 's/\(.*\)\..*/\1/'`; cd $bar; ls; }
This is sample output - yours may be different.
[user@host Downloads]$ wtzc http://www.zlib.net/zlib-1.2.3.tar.gz
--2010-01-17 03:19:56-- http://www.zlib.net/zlib-1.2.3.tar.gz
Resolving www.zlib.net... 69.73.181.135
Connecting to www.zlib.net|69.73.181.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 496597 (485K) [application/x-tar]
Saving to: `zlib-1.2.3.tar.gz'
100%[======================================>] 496,597 337K/s in 1.4s
2010-01-17 03:19:58 (337 KB/s) - `zlib-1.2.3.tar.gz' saved [496597/496597]
zlib-1.2.3/
zlib-1.2.3/adler32.c
zlib-1.2.3/algorithm.txt
zlib-1.2.3/amiga/
zlib-1.2.3/amiga/Makefile.pup
zlib-1.2.3/amiga/Makefile.sas
zlib-1.2.3/as400/
zlib-1.2.3/as400/bndsrc
zlib-1.2.3/as400/compile.clp
zlib-1.2.3/as400/readme.txt
zlib-1.2.3/as400/zlib.inc
zlib-1.2.3/ChangeLog
zlib-1.2.3/compress.c
zlib-1.2.3/configure
zlib-1.2.3/contrib/
zlib-1.2.3/contrib/ada/
zlib-1.2.3/contrib/ada/buffer_demo.adb
zlib-1.2.3/contrib/ada/mtest.adb
zlib-1.2.3/contrib/ada/read.adb
zlib-1.2.3/contrib/ada/readme.txt
zlib-1.2.3/contrib/ada/test.adb
zlib-1.2.3/contrib/ada/zlib-streams.adb
zlib-1.2.3/contrib/ada/zlib-streams.ads
zlib-1.2.3/contrib/ada/zlib-thin.adb
zlib-1.2.3/contrib/ada/zlib-thin.ads
zlib-1.2.3/contrib/ada/zlib.adb
zlib-1.2.3/contrib/ada/zlib.ads
zlib-1.2.3/contrib/ada/zlib.gpr
zlib-1.2.3/contrib/asm586/
zlib-1.2.3/contrib/asm586/match.S
zlib-1.2.3/contrib/asm586/README.586
zlib-1.2.3/contrib/asm686/
zlib-1.2.3/contrib/asm686/match.S
zlib-1.2.3/contrib/asm686/README.686
zlib-1.2.3/contrib/blast/
zlib-1.2.3/contrib/blast/blast.c
zlib-1.2.3/contrib/blast/blast.h
zlib-1.2.3/contrib/blast/Makefile
zlib-1.2.3/contrib/blast/README
zlib-1.2.3/contrib/blast/test.pk
zlib-1.2.3/contrib/blast/test.txt
zlib-1.2.3/contrib/delphi/
zlib-1.2.3/contrib/delphi/readme.txt
zlib-1.2.3/contrib/delphi/ZLib.pas
zlib-1.2.3/contrib/delphi/ZLibConst.pas
zlib-1.2.3/contrib/delphi/zlibd32.mak
zlib-1.2.3/contrib/dotzlib/
zlib-1.2.3/contrib/dotzlib/DotZLib/
zlib-1.2.3/contrib/dotzlib/DotZLib/AssemblyInfo.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/ChecksumImpl.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/CircularBuffer.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/CodecBase.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/Deflater.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.csproj
zlib-1.2.3/contrib/dotzlib/DotZLib/GZipStream.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/Inflater.cs
zlib-1.2.3/contrib/dotzlib/DotZLib/UnitTests.cs
zlib-1.2.3/contrib/dotzlib/DotZLib.build
zlib-1.2.3/contrib/dotzlib/DotZLib.chm
zlib-1.2.3/contrib/dotzlib/DotZLib.sln
zlib-1.2.3/contrib/dotzlib/LICENSE_1_0.txt
zlib-1.2.3/contrib/dotzlib/readme.txt
zlib-1.2.3/contrib/infback9/
zlib-1.2.3/contrib/infback9/infback9.c
zlib-1.2.3/contrib/infback9/infback9.h
zlib-1.2.3/contrib/infback9/inffix9.h
zlib-1.2.3/contrib/infback9/inflate9.h
zlib-1.2.3/contrib/infback9/inftree9.c
zlib-1.2.3/contrib/infback9/inftree9.h
zlib-1.2.3/contrib/infback9/README
zlib-1.2.3/contrib/inflate86/
zlib-1.2.3/contrib/inflate86/inffas86.c
zlib-1.2.3/contrib/inflate86/inffast.S
zlib-1.2.3/contrib/iostream/
zlib-1.2.3/contrib/iostream/test.cpp
zlib-1.2.3/contrib/iostream/zfstream.cpp
zlib-1.2.3/contrib/iostream/zfstream.h
zlib-1.2.3/contrib/iostream2/
zlib-1.2.3/contrib/iostream2/zstream.h
zlib-1.2.3/contrib/iostream2/zstream_test.cpp
zlib-1.2.3/contrib/iostream3/
zlib-1.2.3/contrib/iostream3/README
zlib-1.2.3/contrib/iostream3/test.cc
zlib-1.2.3/contrib/iostream3/TODO
zlib-1.2.3/contrib/iostream3/zfstream.cc
zlib-1.2.3/contrib/iostream3/zfstream.h
zlib-1.2.3/contrib/masm686/
zlib-1.2.3/contrib/masm686/match.asm
zlib-1.2.3/contrib/masmx64/
zlib-1.2.3/contrib/masmx64/bld_ml64.bat
zlib-1.2.3/contrib/masmx64/gvmat64.asm
zlib-1.2.3/contrib/masmx64/gvmat64.obj
zlib-1.2.3/contrib/masmx64/inffas8664.c
zlib-1.2.3/contrib/masmx64/inffasx64.asm
zlib-1.2.3/contrib/masmx64/inffasx64.obj
zlib-1.2.3/contrib/masmx64/readme.txt
zlib-1.2.3/contrib/masmx86/
zlib-1.2.3/contrib/masmx86/bld_ml32.bat
zlib-1.2.3/contrib/masmx86/gvmat32.asm
zlib-1.2.3/contrib/masmx86/gvmat32.obj
zlib-1.2.3/contrib/masmx86/gvmat32c.c
zlib-1.2.3/contrib/masmx86/inffas32.asm
zlib-1.2.3/contrib/masmx86/inffas32.obj
zlib-1.2.3/contrib/masmx86/mkasm.bat
zlib-1.2.3/contrib/masmx86/readme.txt
zlib-1.2.3/contrib/minizip/
zlib-1.2.3/contrib/minizip/ChangeLogUnzip
zlib-1.2.3/contrib/minizip/crypt.h
zlib-1.2.3/contrib/minizip/ioapi.c
zlib-1.2.3/contrib/minizip/ioapi.h
zlib-1.2.3/contrib/minizip/iowin32.c
zlib-1.2.3/contrib/minizip/iowin32.h
zlib-1.2.3/contrib/minizip/Makefile
zlib-1.2.3/contrib/minizip/miniunz.c
zlib-1.2.3/contrib/minizip/minizip.c
zlib-1.2.3/contrib/minizip/mztools.c
zlib-1.2.3/contrib/minizip/mztools.h
zlib-1.2.3/contrib/minizip/unzip.c
zlib-1.2.3/contrib/minizip/unzip.h
zlib-1.2.3/contrib/minizip/zip.c
zlib-1.2.3/contrib/minizip/zip.h
zlib-1.2.3/contrib/pascal/
zlib-1.2.3/contrib/pascal/example.pas
zlib-1.2.3/contrib/pascal/readme.txt
zlib-1.2.3/contrib/pascal/zlibd32.mak
zlib-1.2.3/contrib/pascal/zlibpas.pas
zlib-1.2.3/contrib/puff/
zlib-1.2.3/contrib/puff/Makefile
zlib-1.2.3/contrib/puff/puff.c
zlib-1.2.3/contrib/puff/puff.h
zlib-1.2.3/contrib/puff/README
zlib-1.2.3/contrib/puff/zeros.raw
zlib-1.2.3/contrib/README.contrib
zlib-1.2.3/contrib/testzlib/
zlib-1.2.3/contrib/testzlib/testzlib.c
zlib-1.2.3/contrib/testzlib/testzlib.txt
zlib-1.2.3/contrib/untgz/
zlib-1.2.3/contrib/untgz/Makefile
zlib-1.2.3/contrib/untgz/Makefile.msc
zlib-1.2.3/contrib/untgz/untgz.c
zlib-1.2.3/contrib/vstudio/
zlib-1.2.3/contrib/vstudio/readme.txt
zlib-1.2.3/contrib/vstudio/vc7/
zlib-1.2.3/contrib/vstudio/vc7/miniunz.vcproj
zlib-1.2.3/contrib/vstudio/vc7/minizip.vcproj
zlib-1.2.3/contrib/vstudio/vc7/testzlib.vcproj
zlib-1.2.3/contrib/vstudio/vc7/zlib.rc
zlib-1.2.3/contrib/vstudio/vc7/zlibstat.vcproj
zlib-1.2.3/contrib/vstudio/vc7/zlibvc.def
zlib-1.2.3/contrib/vstudio/vc7/zlibvc.sln
zlib-1.2.3/contrib/vstudio/vc7/zlibvc.vcproj
zlib-1.2.3/contrib/vstudio/vc8/
zlib-1.2.3/contrib/vstudio/vc8/miniunz.vcproj
zlib-1.2.3/contrib/vstudio/vc8/minizip.vcproj
zlib-1.2.3/contrib/vstudio/vc8/testzlib.vcproj
zlib-1.2.3/contrib/vstudio/vc8/testzlibdll.vcproj
zlib-1.2.3/contrib/vstudio/vc8/zlib.rc
zlib-1.2.3/contrib/vstudio/vc8/zlibstat.vcproj
zlib-1.2.3/contrib/vstudio/vc8/zlibvc.def
zlib-1.2.3/contrib/vstudio/vc8/zlibvc.sln
zlib-1.2.3/contrib/vstudio/vc8/zlibvc.vcproj
zlib-1.2.3/crc32.c
zlib-1.2.3/crc32.h
zlib-1.2.3/deflate.c
zlib-1.2.3/deflate.h
zlib-1.2.3/example.c
zlib-1.2.3/examples/
zlib-1.2.3/examples/fitblk.c
zlib-1.2.3/examples/gun.c
zlib-1.2.3/examples/gzappend.c
zlib-1.2.3/examples/gzjoin.c
zlib-1.2.3/examples/gzlog.c
zlib-1.2.3/examples/gzlog.h
zlib-1.2.3/examples/README.examples
zlib-1.2.3/examples/zlib_how.html
zlib-1.2.3/examples/zpipe.c
zlib-1.2.3/examples/zran.c
zlib-1.2.3/FAQ
zlib-1.2.3/gzio.c
zlib-1.2.3/INDEX
zlib-1.2.3/infback.c
zlib-1.2.3/inffast.c
zlib-1.2.3/inffast.h
zlib-1.2.3/inffixed.h
zlib-1.2.3/inflate.c
zlib-1.2.3/inflate.h
zlib-1.2.3/inftrees.c
zlib-1.2.3/inftrees.h
zlib-1.2.3/make_vms.com
zlib-1.2.3/Makefile
zlib-1.2.3/Makefile.in
zlib-1.2.3/minigzip.c
zlib-1.2.3/msdos/
zlib-1.2.3/msdos/Makefile.bor
zlib-1.2.3/msdos/Makefile.dj2
zlib-1.2.3/msdos/Makefile.emx
zlib-1.2.3/msdos/Makefile.msc
zlib-1.2.3/msdos/Makefile.tc
zlib-1.2.3/old/
zlib-1.2.3/old/descrip.mms
zlib-1.2.3/old/Makefile.riscos
zlib-1.2.3/old/os2/
zlib-1.2.3/old/os2/Makefile.os2
zlib-1.2.3/old/os2/zlib.def
zlib-1.2.3/old/README
zlib-1.2.3/old/visual-basic.txt
zlib-1.2.3/old/zlib.html
zlib-1.2.3/projects/
zlib-1.2.3/projects/README.projects
zlib-1.2.3/projects/visualc6/
zlib-1.2.3/projects/visualc6/example.dsp
zlib-1.2.3/projects/visualc6/minigzip.dsp
zlib-1.2.3/projects/visualc6/README.txt
zlib-1.2.3/projects/visualc6/zlib.dsp
zlib-1.2.3/projects/visualc6/zlib.dsw
zlib-1.2.3/qnx/
zlib-1.2.3/qnx/package.qpg
zlib-1.2.3/README
zlib-1.2.3/trees.c
zlib-1.2.3/trees.h
zlib-1.2.3/uncompr.c
zlib-1.2.3/win32/
zlib-1.2.3/win32/DLL_FAQ.txt
zlib-1.2.3/win32/Makefile.bor
zlib-1.2.3/win32/Makefile.emx
zlib-1.2.3/win32/Makefile.gcc
zlib-1.2.3/win32/Makefile.msc
zlib-1.2.3/win32/VisualC.txt
zlib-1.2.3/win32/zlib.def
zlib-1.2.3/win32/zlib1.rc
zlib-1.2.3/zconf.h
zlib-1.2.3/zconf.in.h
zlib-1.2.3/zlib.3
zlib-1.2.3/zlib.h
zlib-1.2.3/zutil.c
zlib-1.2.3/zutil.h
adler32.c crc32.c INDEX inftrees.h qnx zlib.3
algorithm.txt crc32.h infback.c Makefile README zlib.h
amiga deflate.c inffast.c Makefile.in trees.c zutil.c
as400 deflate.h inffast.h make_vms.com trees.h zutil.h
ChangeLog example.c inffixed.h minigzip.c uncompr.c
compress.c examples inflate.c msdos win32
configure FAQ inflate.h old zconf.h
contrib gzio.c inftrees.c projects zconf.in.h
[user@host zlib-1.2.3]$
Combines a few repetitive tasks when compiling source code. Especially useful when a hypen in a file-name breaks tab completion.
1.) wget source.tar.gz
2.) tar xzvf source.tar.gz
3.) cd source
4.) ls
From there you can run ./configure, make and etc.
curl http://example.com/a.gz | tar xz
This is sample output - yours may be different.
find . \! -type d | rev | sort | rev | tar c --files-from=- --format=ustar | bzip2 --best > a.tar.bz2
This is sample output - yours may be different.
Avoids creating useless directory entries in archive, and sorts files by (roughly) extension, which is likely to group similar files together for better compression. 1%-5% improvement.
wget -O - http://example.com/a.gz | tar xz
This is sample output - yours may be different.
Use `tar xj` for bzip2 archives.
tar -cf - . | pv -s $(du -sb . | awk '{print $1}') | gzip > out.tgz
This is sample output - yours may be different.
253MB 0:00:05 [46.7MB/s] [> ] 1% ETA 0:04:49
What happens here is we tell tar to create "-c" an archive of all files in current dir "." (recursively) and output the data to stdout "-f -". Next we specify the size "-s" to pv of all files in current dir. The "du -sb . | awk ?{print $1}?" returns number of bytes in current dir, and it gets fed as "-s" parameter to pv. Next we gzip the whole content and output the result to out.tgz file. This way "pv" knows how much data is still left to be processed and shows us that it will take yet another 4 mins 49 secs to finish.
Credit: Peteris Krumins http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
tar -cvzf arch.tgz $(find /path/dir -not -type d)
This is sample output - yours may be different.
If you give tar a list of filenames, it will not add the directories, so if you don't care about directory ownership or permissions, you can save some space.
Tar will create directories as necessary when extracting.
This command is limited by the maximum supported size of the argument list, so if you are trying to tar up the whole OS for instance, you may just get "Argument list too long".
tar -cvf /path/dir.tar /path/dir* --exclude "/path/dir/name" --exclude "/path/dir/opt"
This is sample output - yours may be different.
Tar - Compress by excluding folders
Tar - Compress by excluding folders
tar -tf /path/to/file.tar
This is sample output - yours may be different.
tar cf - <dir>|split -b<max_size>M - <name>.tar.
This is sample output - yours may be different.
drewfus:~/tmp$ lh
total 9.8G
drwxr-xr-x 2 drew users 4.0K 2009-11-01 09:46 dir
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:26 name.tar.aa
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:27 name.tar.ab
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:28 name.tar.ac
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:29 name.tar.ad
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:30 name.tar.ae
-rw-r--r-- 1 drew users 1.5G 2009-11-10 17:31 name.tar.af
-rw-r--r-- 1 drew users 1.1G 2009-11-10 17:32 name.tar.ag
Create a tar file in multiple parts if it's to large for a single disk, your filesystem, etc.
Rejoin later with `cat .tar.*|tar xf -`
for F in $(find ./ -name "*.tgz") ; do tar -tvzf $F ; done
This is sample output - yours may be different.
[alchandia@localhost Cacti]$ tar -tvzf cacti-iostat-1.3.tgz
drwxr-xr-x alchandia/users 0 2009-05-18 06:02:27 cacti-iostat-1.3/
drwxr-xr-x alchandia/users 0 2009-05-18 06:02:27 cacti-iostat-1.3/scripts/
-rwxr-xr-x alchandia/users 5087 2009-05-18 06:02:12 cacti-iostat-1.3/scripts/iostat.pl
The magic is performed by the parameter -t
find <path> -name "*.tgz" -or -name "*.tar.gz" | while read file; do echo "$file: "; tar -tzf $file; done
This is sample output - yours may be different.
This script will list all the files in the tarballs present on any folder or subfolder of the provided path. The while loop is for echoing the file name of the tarball before listing the files, so the tarball can be identified