Sponsored Content
Top Forums Shell Programming and Scripting Converting Huge Archive into smaller ones Post 302247832 by rubin on Thursday 16th of October 2008 12:03:22 PM
Old 10-16-2008
Nice solution ...

and a few suggestions:
- You can consolidate all the commands in one script,
- and you can use the sleep command within the script, instead of setting up a cron process, running every 2 min,


checkAndGzip.sh

Code:
#!/bin/bash

#set -x


# Provide full path, so you can run the script from every dir.
cd /full/path/to/zipped_files

# Start unzipping the files, run it in the background so the files checking can start.
gunzip -c archive.tar.gz | tar -xvf -   &

# Start checking for the files, while the unzipping is happening. 
# Use a find ...| while read ... construction , because it doesn't break if the file name has white space in it.

 find . -name '*.extension' | while read FILE      2>/dev/null
  do
        temp=`lsof "$FILE" | awk 'NR>1 && $4 ~ "w"{ print $4 }'` ;
        
        if [ "$temp" = "" ]; then
                #Implies that the file is not in use
                #Initiate gzip on file
                gzip "$FILE";
        fi
    
        # Wait for 2 minutes.
        sleep 120

  done > output

Modify the code to fit any other requirement.
 

8 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Smaller splash graphic

Not to complain, but the large graphic at the top of the page ensures that I have to scroll down everytime I change pages. Maybe the problem is the 1024x768 of my laptop screen, but it does seem excessive. Keith (2 Replies)
Discussion started by: kduffin
2 Replies

2. UNIX for Dummies Questions & Answers

Anything smaller than sleep 1

I'm writting a shell script to email customers invoices. after each RCPT to: email@address.com, i've put in a sleep 1 command, but with 2000 customers to email and about 5 or 6 of these sleep commands it can take a very long time. Is there any smaller amount of time the sleeper can sleep for... (4 Replies)
Discussion started by: markms
4 Replies

3. Shell Programming and Scripting

Grab a smaller and larger value

Hi All, I am trying to grab a term which is just smaller and larger than the assigned value using the below code. But there seems to be some problem. The value i assign is 25 so i would expect it to output a smaller value to be 20 instead of 10 and 20 and larger value to be 30 instead of 30 and... (3 Replies)
Discussion started by: Raynon
3 Replies

4. Shell Programming and Scripting

Extracting from archive | compressing to new archive

Hi there, I have one huge archive (it's a system image). I need sometime to create smaller archives with only one or two file from my big archive. So I'm looking for a command that extracts files from an archive and pipe them to another one. I tried the following : tar -xzOf oldarchive.tgz... (5 Replies)
Discussion started by: chebarbudo
5 Replies

5. Shell Programming and Scripting

Number of lines smaller than specified value

Hi All, I have a problem to find number of lines per column smaller than the values given in a different file. In example, compare the 1st column of file1 with the 1st line of the file2, 2nd column of file1 with the 2nd line of the file2, etc cat file1 0.2 0.9 0.8 0.5 ... 0.6 0.5... (9 Replies)
Discussion started by: senayasma
9 Replies

6. Shell Programming and Scripting

Converting huge xls(having multiple tabs) to csv

hello I have browsed for the similar requirement i found this https://www.unix.com/shell-programming-scripting/40163-xls-csv-conversion.html but my problem is i have multiple tabs in xls file having same metadata I want to convert it into single csv file any ways to do it pls... (5 Replies)
Discussion started by: joshiamit
5 Replies

7. Shell Programming and Scripting

Breaking out ip subnet to smaller subnets

I have a script and it works fine, but I am sure this can be shrunk down to something much better. I would appreciate someone taking a crack at it for me. What it does is take the ip block submitted and breaks it out down to /24's. #!/bin/ksh ipadd=${1} octet1=`echo $ipadd | nawk -F.... (3 Replies)
Discussion started by: numele
3 Replies

8. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies
Archive::Any(3pm)					User Contributed Perl Documentation					 Archive::Any(3pm)

NAME
Archive::Any - Single interface to deal with file archives. SYNOPSIS
use Archive::Any; my $archive = Archive::Any->new($archive_file); my @files = $archive->files; $archive->extract; my $type = $archive->type; $archive->is_impolite; $archive->is_naughty; DESCRIPTION
This module is a single interface for manipulating different archive formats. Tarballs, zip files, etc. new my $archive = Archive::Any->new($archive_file); my $archive = Archive::Any->new($archive_file, $type); $type is optional. It lets you force the file type in-case Archive::Any can't figure it out. extract $archive->extract; $archive->extract($directory); Extracts the files in the archive to the given $directory. If no $directory is given, it will go into the current working directory. files my @file = $archive->files; A list of files in the archive. mime_type my $mime_type = $archive->mime_type(); Returns the mime type of the archive. is_impolite my $is_impolite = $archive->is_impolite; Checks to see if this archive is going to unpack into the current directory rather than create its own. is_naughty my $is_naughty = $archive->is_naughty; Checks to see if this archive is going to unpack outside the current directory. DEPRECATED
type my $type = $archive->type; Returns the type of archive. This method is provided for backwards compatibility in the Tar and Zip plugins and will be going away soon in favor of "mime_type". PLUGINS
For detailed information on writing plugins to work with Archive::Any, please see the pod documentation for Archive::Any::Plugin. AUTHOR
Clint Moore <cmoore@cpan.org> AUTHOR EMERITUS
Michael G Schwern SEE ALSO
Archive::Any::Plugin SUPPORT
You can find documentation for this module with the perldoc command. perldoc Archive::Any You can also look for information at: o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Archive-Any> o CPAN Ratings <http://cpanratings.perl.org/d/Archive-Any> o RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Archive-Any> o Search CPAN <http://search.cpan.org/dist/Archive-Any> LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.10.0 2008-06-25 Archive::Any(3pm)
All times are GMT -4. The time now is 11:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy