Never been to DZone Snippets 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

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

unix, pack folder and contents with tar gz

tar -zcvf packagename.tar.gz folder/

Avoiding tar's (or any other commandline's) argument list too long error

When you try to tar a large number of files (cp, mv, or anything else) you may hit the limit of ARG_MAX. You can overcome this by generating a list of files then feeding it to tar as follows:

# generate the file list
find -iname '*.ext' > fileList.txt

#run tar passing it the file list
tar czvf archive.tar.gz --files-from fileList.txt

# a shorthand of this would be:
find . -name '*.ext' -print | tar -cvzf archive.tar.gz --files-from -

UNIX tar Commands

// how the heck do you do the stuff you do with zip but with tar

create tar file
tar cvf filename.tar monkey.txt monkey2.txt

add a file
tar uvf filename.tar monkey.txt

extract tar file
tar xvf filename.tar

list contents
tar tf monkey.tar

ssh remote backups

// http://www.linux.com/article.pl?sid=06/01/12/1937210
// Backup with remote compression and storage

// When compression is necessary (and feasible), workload
// distribution becomes more effective with OpenSSH. Just as // distcc allows multiple machines to compile
// simultaneously, OpenSSH lets one system create the
// archive, while another system compresses it:

// tar cf - dirname | ssh remotehost "gzip -c >
// ${TMPFILE}.tar.gz"

tar cf - local-dir-eliotwalker | ssh -l mctt remote-glos.corruptive.co.uk "gzip -c > corr.tar.gz"
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS