Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

unpacking gzip'd tar'd files

// description of your code here

gunzip -c <tgz file> | tar xvf -

using tar to archive files


tar -czf <tar file> <file to archive>[...]


To get all files, including hidden files, specify the current directory rather than *

tar -czf <tar file> .

Tar up, excluding common media extensions

Just the code, please! Hop in the dir you want to back up (note: this means it'll expand without a base directory, so do a mkdir/cd first!)

find . ! -type d -print | egrep '/,|%$|~$|\.old$|\.mpg$|\.zip$|\.wmv$|\.mp3$|\.MP3$|\.mp4$|\.MP4$|\.av2$|\.ppt$|\.dir$|\.pps$|\.qt$|SCCS|/core$|\.o$|\.orig$|\.mpeg$|\.mov$|\.doc$|\.xls$|\.pdf$|\.swf$|\.fla$|\.wav$|\.aif$|\.aiff$|\.mp3$|\.jpg$|\.JPG$|\.jpeg$|\.JPEG$|\.gif$|\.GIF$|\.png$|\.PNG$|\.psd$|\.PSD$|\.tar.gz$|\.tgz$|\.TGZ$|\.tif$|\.TIF$|\.tiff$|\.TIFF$|\.tga$|\.TGA$|\.ram$|\.rm$|\.rma$|\.psd$|\.PSD$|\.ai$|\.AI$' > Exclude
tar czfvX ~/backup_text_back.tgz Exclude .

tar and gzip on one line

Bundle my_dir
tar cvf - my_dir | gzip -c > my_dir.tar.gz


Unbundle my_dir
gunzip -c my_dir.tar.gz | tar xvf -

tar syntax

// tar:
tar -cvzf file.tar.gz inputfile1 inputfile2


// untar:
tar -xvzf file.tar.gz

Create an archive with tar

// description of your code here

tar czf project.tar.gz project/