Scripting data, day after


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting data, day after
# 1  
Old 08-21-2009
Lightbulb 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:

Code:
#!/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:
Code:
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

Last edited by Franklin52; 08-21-2009 at 08:28 AM.. Reason: adding code tags
# 2  
Old 08-21-2009
Code:
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

Last edited by Franklin52; 08-21-2009 at 08:28 AM.. Reason: adding code tags
# 3  
Old 08-21-2009
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 [code] and [/code] 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
# 4  
Old 08-21-2009
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

Last edited by voltaza; 08-21-2009 at 08:31 AM..
# 5  
Old 08-21-2009
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...

Code:
#!/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

# 6  
Old 08-21-2009
Code:
#!/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

# 7  
Old 08-21-2009
Quote:
Originally Posted by sagar_evc
Code:
#!/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 Smilie

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

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

Last edited by voltaza; 08-21-2009 at 08:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the consecutive last 10 week day date using UNIX ksh shell scripting?

Hi, i am writing a ksh shell script to check the last month end date whether it is falling in last 10 week day date, I am not sure How to use "Mr. Perderabo's date calculator", Could you Please let me know how to use to get my requirement, I tried my own script but duplicate week day and... (5 Replies)
Discussion started by: karthikram
5 Replies

2. Shell Programming and Scripting

Julian day to dates in YEAR-MONTH-DAY

hello, I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc. I need to do it for several years and leap years as well. What is the best way to do it ? Thank you. (1 Reply)
Discussion started by: Ggg
1 Replies

3. Shell Programming and Scripting

Replace data of a file with data from another file using shell scripting.

Dears, I'm new to shell scripting and i was wondering if you can help me with following matter. I have a file containing 400,000 records. The file contains two columns like: 00611291,0270404000005453 25262597,1580401000016155 25779812,1700403000001786 00388934,1200408000000880... (1 Reply)
Discussion started by: paniklas
1 Replies

4. AIX

wtmp file - is there a patch to export the data another file each day?

sorry for being a noob, i am trying to find which user accessed the server at what time and there ip address at first i used who command but the output didn't contain the ip address then i used the last command which provided me with the ip of the users but when i searched i searched and found that... (1 Reply)
Discussion started by: hercules_1010
1 Replies

5. Shell Programming and Scripting

Append data to new row in CSV file every day

Hi All I will run the same script every day in corn and output should go to same CSV file but in different row with dates on it. Below is my example in attached format. Script i am using to collect switch port online DATE=`date '+%d-%m-%y'` for f in `cat... (1 Reply)
Discussion started by: ranjancom2000
1 Replies

6. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

7. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

8. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

9. UNIX for Dummies Questions & Answers

I want to seperate my data by time of day

Hi, I'm a newbie to unix. I have a txt file with my data, a list of events. Each event comes with a unix time. I want to seperate a months worth of events into those that occur during the day, and those at night. I have no clue how to go about this, please can someone push me in the right... (6 Replies)
Discussion started by: pmasterkim
6 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question