The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copy and compress here2learn UNIX for Dummies Questions & Answers 5 03-08-2009 01:10 PM
combining mv and compress command sam_78_nyc Shell Programming and Scripting 4 11-06-2007 03:45 PM
Compress command indira UNIX for Dummies Questions & Answers 5 08-20-2007 02:04 PM
Compress and copy a Folder scorpiyanz UNIX for Advanced & Expert Users 1 08-19-2005 01:53 PM
Help on compress command rahulrathod SCO 1 09-28-2004 04:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 10-13-2007
findprakash findprakash is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 31
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>

Thanks,
Prakash
  #2 (permalink)  
Old 10-14-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
something like

Code:
find /source -type f | while read N
do
      mkdir -p /target/`dirname $N`
      compress <$N >/target/$N
done
  #3 (permalink)  
Old 10-15-2007
findprakash findprakash is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 31
Thanks porter. This is exactly was I was looking for.
  #4 (permalink)  
Old 11-24-2007
findprakash findprakash is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 31
I used below code as suggested by Porter for compressing and copying directory.

find ${COPY_DIR} -type f | while read N
do
mkdir -p "${BACKUP_DIR}/`dirname $N`"
gzip < $N > ${BACKUP_DIR}/$N.gz
done

However I have some directories which have space in name. I get below error when copying and compressing directories which have sapce in name.

/backup/sidora/iAS/ifs1.1/doc/Quick Tour/Graphics/rtarr.gif.gz: cannot create

Any ideas on how can I take fix above error. Thanks in advance.
  #5 (permalink)  
Old 11-24-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
replace this to

Code:
gzip < $N > ${BACKUP_DIR}/$N.gz
Code:
gzip < "$N" > "${BACKUP_DIR}/$N.gz"
  #6 (permalink)  
Old 11-24-2007
findprakash findprakash is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 31
Thanks for update matrixmadhan. Even though after making suggsted changes I still get same error message. Now my code looks like :

find ${COPY_DIR} -type f | while read N
do
mkdir -p "${BACKUP_DIR}/`dirname $N`"
gzip < "$N" > "${BACKUP_DIR}/$N.gz"
done

Error message

/backup/sidora/iAS/ifs1.1/doc/Quick Tour/Graphics/rtarr.gif.gz: cannot create
  #7 (permalink)  
Old 11-24-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Just to make sure, do you have enough permissions to create the file in the specified directory ?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0