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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compress and move files in many directories

Status
Not open for further replies.

abbyr129

Technical User
Aug 29, 2003
1
US
I have 30 or so directories in a /logs directory. I need to monthly compress all files for previous month in each subdirectory, create a new dir (ex. previouse month 2003-Jul) and then move them to that new subfolder.

Currently the file is:
/logs/dr1/filename.log
compress and move to:
/logs/dr1/2003/Jul)

I am new to unix and don't want this to be a manual process - want it to be in a script I can run at the start of the new month.

Any suggestions?
 
You can do this by using the command find.
Do a man "find", and look at the options for the "-exec" option.
To create the directory use the command "date" (to get todays date, and then use the comamnd "if" to chech if the directory you require exists and if not create it.

Some us here could do this easely, but I think it is better if you try and do it yourself, and come back to us if you have problems with the code you create.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top