Scripting data, day after

Hi there,

Im having a problem with my script... dont now how to finish.

I have a more than 50 files in folder where is myscript. I manage to make this script work but i have a problem with files i want to send. We talk about .log files. My script look like this:

#!/bin/sh.
more subscriber.log | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

but i have a problem because i dond need subscriber.log i need subscriber.log from day before etc. subscriber.log.2009-08-15 and it should be generated for every day but a date should be from yesterday.

my log looks like this:

subscriber.log.2009-08-13
subscriber.log.2009-08-14
subscriber.log.2009-08-15

my script should also do the grep and the FTP but i manage to do this, i just dont know how to force this script to take log file form yesterday.

please help, and thanks

sincerly yours Voltaza

find <directory> -mtime +1 -name <pattern of the file name> -exec ls -el {} \;

This command should give you the file created a day earlier. You cut the file name field and use in your script.

S

Both of you, please read the following, ty:

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

Thanks mate,

but i dont know where to put this line? before grep ? Is this the first line in my script? I also have to automate this script so it can work every day... i need that this script use log file from yestrday from all logs in this dir.

cool zaxxon. tnks

#!/bin/sh.
find <directory> -mtime +1 -name subscriber* -exec ls -el {} \; >> temp.file
#cut the last field to get the file name and assign it to a variable filname
more $filname | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

this code give me log file from today 21 and i need a file from yestrday subscriber.log.2009-08-20 my last field is subscriber.log and no date...

#!/bin/sh.
find <directory> -mtime +1 -name subscriber* -exec ls -el {} \; >> temp.file
#cut the last field to get the file name and assign it to a variable filname
more $filname | grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

this code give me log file from today 21 and i need a file from yestrday subscriber.log.2009-08-20 my last field is subscriber.log and have no date... This log i generated just now and a dont need log from today... i need a log from 2009-08-20

---------- Post updated at 01:44 PM ---------- Previous update was at 01:34 PM ----------

? help :slight_smile:

---------- Post updated at 01:56 PM ---------- Previous update was at 01:44 PM ----------

I dont need last file... i need file before that....

temp=`date '+%d'`
temp=`expr $temp - 1`
echo subscriber.log.`date +%Y-%m-`$temp

This should give you the yesterday's file name

is this the first line and than i do grep?
thank mate... im in hell...

#!/bin/sh.
temp=`date '+%d'`
temp=`expr $temp - 1`
filename='echo subscriber.log.`date +%Y-%m-`$temp'
more $filename| grep Purchase subscriber.log > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

Im done IT! Thanks a LOT!

---------- Post updated at 02:17 PM ---------- Previous update was at 02:07 PM ----------

#!/bin/sh.
temp=`date '+%d'`
temp=`expr $temp - 1`
more subscriber.log.`date +%Y-%m-`$temp | grep Purchase subscriber.log.`date +%Y-%m-`$temp > dacha
ftp -v -n "10.15.20.245" <<cmd
user "fun" "fun"
send dacha
quit
cmd

This is a command, when i use for grep just subsciber.log scrip always give me log from today... is is a solution... thanks for backup!!!!

Is this a question? Sorry, I didn't get you

No, i finished this... tnx mate!!!! Very....