Copy and compress


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copy and compress
# 1  
Old 11-28-2005
Copy and compress

Is there a way to copy a file and compress it at the same time?

I realize the file can be copied and then compressed, but I was wondering if it's possible to do it in a one-line command and for that matter, if it would be more efficient to perform the operation with a one-line command?

Thanks.
# 2  
Old 11-28-2005
# 3  
Old 11-29-2005
Thanks JYOUNG. That allowed me to accomplish the task albeit not with a one-line command.

It appears that copying & gzipping thru a pipe isn't any faster than copying, gzipping & moving a 120MB file.

Guess I'll stick w/ the non-PIPE procedure.

Last edited by here2learn; 12-03-2005 at 06:59 PM..
# 4  
Old 11-29-2005
Not sure that you need a pipe, perhaps try...
Code:
gzip < /path/to/file1 > /path/to/file1.gz

# 5  
Old 11-30-2005
That's what I was looking for !! MAN, for the life of me, I can't believe I didn't remember that option. Bet I won't forget it next time.

It seems the the times are approximately the same for all three methods, however Ygor's method does provide the one-line code I was looking for and prevents having to remove any named-pipe.

Thanks Ygor !!
# 6  
Old 03-08-2009
copy and compress without itermediate files

To compress:

Code:
tar cf - <space_separated_list_of_files/folders> | gzip -c - > <path>/<archive_name>.tar.gz

To uncompress:

cd to the directory you want the files extracted in and run:

Code:
gunzip -c <path>/<archive_name>.tar.gz | tar xf -

(On Solaris, be sure to add the option E to the tar creation command arguments. i.e. tar cEf ...)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help - To copy and compress files one day ago

Hi dears, Hi All, I'm a new member of this Forum. I have need your help to handle this request. "I want to copy and Compress files not of today but of yesterday only using some script". For example I have the following files under a particular directory in a Solaris machine. ... (7 Replies)
Discussion started by: JackyJohn
7 Replies

2. Web Development

Compress then Delete

Hi all, Someone please help with a script that will compress a directory for backed up: home/main/directory2Bcompressed/ home/main/directory2Bcompressed_date.zip Then all the files in the directory are to be deleted right afterwards, emptied out for new files to come in: ... (6 Replies)
Discussion started by: MrDude
6 Replies

3. Shell Programming and Scripting

compress folder

hi guys, i've read that i need to use tar first before gzip. just wanted to be sure if there's no way of compressing a folder with all its files like winzip in windows? using tar then gzip in unix, i will need to open 2 zip files in order to get the files unlike winzip. i'd appreciate any... (2 Replies)
Discussion started by: adshocker
2 Replies

4. UNIX for Dummies Questions & Answers

Issue: Compress in unix server and FTP to windows and open the compress file using Winzip

Hi All ! We have to compress a big data file in unix server and transfer it to windows and uncompress it using winzip in windows. I have used the utility ZIP like the below. zip -e <newfilename> df2_test_extract.dat but when I compress files greater than 4 gb using zip utility, it... (4 Replies)
Discussion started by: sakthifire
4 Replies

5. UNIX for Dummies Questions & Answers

What is in-core copy and disk-copy of i-node table?

I have found a question from the exercises of my study mat. The question is "Why are there a in-core copy and a disk-copy of i-node block and super block?" If any one know the proper answer then please send me..... (1 Reply)
Discussion started by: dearanik
1 Replies

6. UNIX for Dummies Questions & Answers

Copy Compress as one command

Hi, I need to copy and compress files in a directory in single line of command. I am able to copy and gzip files in one command but not directory. Command that I am using for copying directory is below : cp -rp /u01/app/<directory> /u01/app/backup |gzip -r /u01/app/backup/<directory> ... (10 Replies)
Discussion started by: findprakash
10 Replies

7. UNIX for Dummies Questions & Answers

Need help to compress

People i have files.arc i need to compress one by one...but they need to have the same date for example jan 30 1234.arc jan 30 12334.arc jan 30 rejrne.arc jan 30 e423e4.arc jan 30 afdhnfhd.arc jan 31 aresdfds.arc I need to compres the jan 30 .arc only thank you very much (1 Reply)
Discussion started by: enkei17
1 Replies

8. UNIX for Advanced & Expert Users

Compress and copy a Folder

hi Buddies , How can i Compress and move a folder through UNIX completely to windows 2000 through FTP. (1 Reply)
Discussion started by: scorpiyanz
1 Replies

9. SCO

Help on compress command

Hello. Can any1 help me with the compress command. The -b option takes the number of bits used for encoding. can u expalin why this number of bits is used and for what purpose. what is the maximum number we can provide? In SFU these number has a valod range between 12 and 16 y?? (1 Reply)
Discussion started by: rahulrathod
1 Replies

10. UNIX for Advanced & Expert Users

Details of compress -b

Hello. Can any1 help me with the compress command. The -b option takes the number of bits used for encoding. can u expalin why this number of bits is used and for what purpose. what is the maximum number we can provide? In SFU these number has a valod range between 12 and 16 y?? (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question