LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 12: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, 03:47 PM   #2
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

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 03:48 PM.
 
Old 10-13-2009, 06:11 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

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


Reply



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 10:59 AM
Script tar+gzip traverse a directory gn00kie Programming 7 06-16-2006 01:52 AM
script to gzip all directories in a directory br8kwall Programming 11 09-06-2005 10:42 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
gzip a directory into a file tcma Linux - Software 4 10-07-2004 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:16 PM.

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
Open Source Consulting | Domain Registration