Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manage gzipped files using script 1

Status
Not open for further replies.

akelabanda

Programmer
Dec 19, 2001
61
IN
Hi Guys

Hope you can help me with this.

I have to deal with a set of file that come in everyday.

Example
x1
x2
x3.gz
x4.gz
x5.gz
x6.gz
x7.gz
x8
x9
x10

In the example above, I have to pick the oldest file from the list and process it (x1, x2, x3, etc). However, to save on space, there is a job running in the background that gzips these files (x3 - x7).

Also, there are new files that come in (x8 - x10).

At present, the job that processes these files picks all unzipped files. So, the problem is, it's going to pick x8 after finishing x1, x2 which is wrong.

I would like to run a ls -1tr | head -1 which gives me the oldest file in the list. If it's gzipped, want to unzip it and let the program pick the correct sequence.

Any ideas / code bits that can be helpful will be great.

Oooh.. That's a long question, just realised.

Thanks guys.

Raj

UK's best mobile deals online
 
Hi

Do not understand. I would process the files in order by name and when the [tt]file[/tt] command says the file is compressed, then uncompress it before processing.

Feherke.
 
What have you tried so far... i.e. which bit exactly are you having trouble with, since you seem to know what you want to do?

Annihilannic.
 
Perhaps just put a gunzip command in for every pass, directing error to /dev/null in the event that the file hasn't been gzipped.

I don't mind people who aren't what they seem. I just wish they'd make their mind up.

Alan Bennett.
 
One thing to be aware of... if the file is still in the process of being gzipped when you run the ls -ltr command it may not be listed in the correct order. gzip does apply the timestamp of the original file to the gzipped file, but only after the gzip operation completes.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top