The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
to get a line above the search word sachin.gangadha UNIX for Dummies Questions & Answers 16 01-07-2008 04:19 AM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 07:24 AM
search whole line using grep useless79 Shell Programming and Scripting 1 11-23-2007 02:14 AM
search and replace the whole line Jartan Shell Programming and Scripting 17 09-25-2007 10:58 AM
search a long line mpang_ Shell Programming and Scripting 14 03-21-2007 04:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-25-2007
Registered User
 

Join Date: Dec 2007
Posts: 8
Question Search, Tar and Compress in one line

Hi all,

I am supposed to collect a huge amount of log files from a unix system (HP-UX) onto a local system. The log files are not in one place, but they are scattered all over the Unix server. The unix server has only limited space, so that I can not create a tar file first and then compress it. I am trying to do something like tar -cvf | gzip -c but it fails due to spaces in the file name.
The command I am trying is:
find /BaseDirectory -name "*.log" | xargs tar -cvf | gzip -c > AllLogFiles.tgz
I am getting errors like:
tar: cannot stat ./BACKUP/24-11-2007. Not dumped.
tar: cannot stat 02.52.45-BACKUP.log. Not dumped.
tar: cannot stat ./BACKUP/24-11-2007. Not dumped.
tar: cannot stat 02.56.40-BACKUP.log. Not dumped.
tar: cannot stat ./BACKUP/24-11-2007. Not dumped.

Is it because of spaces or hyphens in the file name? Or am I trying a wrong command? (Original filenames are like "24-11-2007 02.53.32-BACKU.log")

Alternatively, Is there any way that I can collect all *.log files into one compressed file (so that the command doesn't error out due to lack of space while collecting log files)? The actual archive type is not important, it could be gzip, compress, pack or anything.

Thanks for reading my query, and have a nice day/evening.
Reply With Quote
Forum Sponsor
  #2  
Old 12-25-2007
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Hi,
How about search, cpio and compress ? since tar is just an archiver as well as cpio which does no compression at all ?
Code:
find . -name "*.log" -print | cpio -o | gzip -c > AllLogFiles.cpio.gz # to compress
gzip -dc AllLogFiles.cpio.gz | cpio -i # to decompress
Reply With Quote
  #3  
Old 12-25-2007
Registered User
 

Join Date: Dec 2007
Posts: 8
Thanks andryk, that was real quick.
I executed that on a small folder, and the first command worked properly. However, the second one is giving error:
missing 'd' option
Cannot create directory for <mainlog> (errno:2)
missing 'd' option
Cannot create directory for <BACKUP> (errno:2)
missing 'd' option
Cannot create directory for <BACKUP> (errno:2)
missing 'd' option
Cannot create directory for <BACKUP> (errno:2)
....
....

Any ideas?
Reply With Quote
  #4  
Old 12-25-2007
Registered User
 

Join Date: Dec 2007
Posts: 8
I added -d to cpio and the problem is solved.

Thanks andryk, you have saved me a lot of trouble, and it was quick.. This forum is amazing...
Reply With Quote
  #5  
Old 12-26-2007
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
Well, glad i could help ... and sorry i forgot that 'd', first time using cpio
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
cpio

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0