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!

find file with script that ends in .2005-09-01 date format.

Status
Not open for further replies.

sco1104

IS-IT--Management
Feb 5, 2001
9
US
I need help with a linux script to find, zip and ftp to a windows based cluster on a particular drive. I want to find "yesterdays" file ending in 2005-09-05

to find the file I have tried

find /home/path/to/file/server.log.'date --date='yesterday' '+%Y%-%m-%d' (this doesn't seem to find the file).

Then would I pipe that into gzip??

Some help in the right direction would be great. Thanks
 

Try:

Code:
find /home/path/to/file/server.log.`TZ=PST+24 date +%Y-%m-%d`
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 

Ooops, typo in above find command, it should be:
Code:
find /home/path/to/file -name "server.log.`TZ=PST+24 date +%Y-%m-%d`"

Or to gzipit directly do:
Code:
gzip /home/path/to/file/server.log.`TZ=PST+24 date +%Y-%m-%d`
[noevil]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Thanks for the help but I am wondering if my log files are generated in this format server.log.2005-09-06 will this work? Will the date be formatted correct?
 

Try it. [wink]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
I tried and it found no file. I confirmed the file is there. Would it make a difference if my system is running GMT?
 


Did you try it? [ponder]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Yes I tried it and it did not find the file.
 
And this ?
gzip /home/path/to/file/server.log.`date --date=yesterday +%Y-%m-%d`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry, I double posted the "try it". [morning]

OK PHV's option works -- or if you have GMT then this also works:

gzip /home/path/to/file/server.log.`TZ=GMT+48 date +%Y-%m-%d`



----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Yes the second one did work.

Thanks for all the help
 


Also I beleive it works if you replace 48 with 24:

gzip /home/path/to/file/server.log.`TZ=GMT+24 date +%Y-%m-%d`


[2thumbsup]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top