LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-13-2009, 01:37 PM   #1
Ciik13
LQ Newbie
 
Registered: Sep 2009
Posts: 4

Rep: Reputation: 0
Trying to gzip all my files in one directory then save in another directory


using 10.0.0 Darwin Unix version
How would i go about writing a command line to take all my files in a certain directory, gzip them, and then save in another directory

Doing a python tutorial and this is one of the problems it poses..
any help would greatly be appreciated!
 
Old 10-13-2009, 04:47 PM   #2
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 438

Rep: Reputation: 57
If you want to create a tarball to backup all of your files to another directory, try this:

tar -cvzpf /newdirectory/newfile.tgz /olddirectory

Then you would expand/restore it like this: tar -C /restoredirectory -xvzpf /newdirectory/newfile.tgz
Or simply tar -xvzpf newfile.tgz to just expand it in place.

The c switch is "create"
The x is "extract"
The z is "gzip" (if supported - depends on distro)
The p is "permissions" (it keeps all your permissions the intact, rather than using umask)
The f is "file"

http://en.wikipedia.org/wiki/Tar_%28file_format%29


This won't help you with the python aspect necessarily

Last edited by MBybee; 10-13-2009 at 04:48 PM.
 
Old 10-13-2009, 07:11 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If you want to do it just with gzip you can; see the examples here http://linux.die.net/man/1/gzip
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to unzip and gzip files into directory, eldaria Programming 3 03-16-2007 11:59 AM
Script tar+gzip traverse a directory gn00kie Programming 7 06-16-2006 02:52 AM
script to gzip all directories in a directory br8kwall Programming 11 09-06-2005 11:42 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM
gzip a directory into a file tcma Linux - Software 4 10-07-2004 03:51 AM


All times are GMT -5. The time now is 10:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration