Script to filter by date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to filter by date
# 1  
Old 10-25-2012
Script to filter by date

Hello,

I currently have the need to perform backup, naming the file by date. How do I get the script, you can choose the most current file or current date and then upload it? My script is related to this topic that is already closed.

Read Post

Can anyone help me?
# 2  
Old 10-25-2012
The most popular tool for this is 'find ... -newer' with a marker file. Just remember that UNIX time is in seconds, and you do not want to miss files dated on the critical second. I recall I touched a new marker file, waited a second, and then found and processed all files newer than old marker. Files last modified after that second as I ran find might get picked up again in the next run but be identical. You can tell find and not newer than new marker. Move the new marker to be the old marker at successful completion. Check all exit codes!

You can configure rsync and have backup be a continuous process if the output is another subtree or host.
This User Gave Thanks to DGPickett For This Post:
# 3  
Old 10-25-2012
Sorry, but I applied the command and did not return the result I wanted. For example, I have 2 files in a directory and they are named like this:

www-Wed-24-Oct-20-00.tar.gz and www-Wed-24-Oct-10-48.tar.gz

How should I apply the command so that it would return the file 8 o'clock that the most current ?
# 4  
Old 10-25-2012
For the most current, something like:
Code:
ls -t | head -1

This User Gave Thanks to DGPickett For This Post:
# 5  
Old 10-25-2012
if its only for the same date and same month then try using this..

Code:
ls www* | sort  -t"-" -k5 -r

This User Gave Thanks to msabhi For This Post:
# 6  
Old 10-26-2012
Yes, sometimes file get accidentally touched (updated modify time) when they did not change.
This User Gave Thanks to DGPickett For This Post:
# 7  
Old 10-26-2012
Hi, good afternoon. I've managed to get to the command that desire. It is this:

Code:
find /DIRECTORY -iname "*.sql" -mtime -1

Now, I want the output of this command, which is the value "db-Thu-25-Oct-20-00.sql" it is recognized by a file that will upload the same. I already have the upload script. I do not know how do I relate this value to my file upload. How do I do this?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Filter log file contents between date

Hi, Could you please provide me command to filter contents between date in a log file? Say for example, in a log file I want to capture contents between date May 01 from 5am to 9 am. OS -- Linux Regards, Maddy (1 Reply)
Discussion started by: Maddy123
1 Replies

2. Shell Programming and Scripting

How to filter date input in awk?

Hi, I've no problems filtering text in awk but whenever I try to filter date format such as 03022013, I couldn't get awk to filter the item out. Any tips? (8 Replies)
Discussion started by: commonwealth
8 Replies

3. Shell Programming and Scripting

Date capture & filter

Dear All, I am capturing system date and creating the file by using that time stamp, file is getting appended with checks of application & database check logs. But when the date is in between 1 to 9 both inclusive, it appends a single space to file name but after 9th it works fine. ... (5 Replies)
Discussion started by: pradeep84in
5 Replies

4. Shell Programming and Scripting

how to filter file for specific date

Hi My OS is solaris 64 bit 10, I have many files in a logs directory where we recive 40-50 logs every day. i have last 20 days file present in this directory. I want to move each day file to a particulaar directory whose name is appended with the date of file. eg Code: 1.txt file... (1 Reply)
Discussion started by: guddu_12
1 Replies

5. Shell Programming and Scripting

find command to filter specific type of files older than certain date.

Hi I need to find the list of files in a directory and to do some specific operations based on the type of files. suppose in a directory am having .dat , .log, .err, .rej file types. i need to filter out .dat and .log only which are older than six months. i used the below query but the... (2 Replies)
Discussion started by: msathees
2 Replies

6. Shell Programming and Scripting

Filter date and time form a file using sed command

I want to filter out the date and time from this line in a file. How to do this using sed command. on Tue Apr 19 00:48:29 2011 (12 Replies)
Discussion started by: vineet.dhingra
12 Replies

7. Shell Programming and Scripting

Grep script to filter

Hi, Wondering if anyone could help me with a simple script to filter out multiple things from a file. Right now I just have long lines of grep -v remove file | greg -v etc etc What I would like to do is have grep -v <run everything in a file> tofilter If that makes sense. Basically a... (2 Replies)
Discussion started by: kevin9
2 Replies

8. Shell Programming and Scripting

Filter by modify date.

I want to filter an "ls -al" command so it only shows me files with modify dates older than two weeks. What is the best way of doing this? (2 Replies)
Discussion started by: millerdc
2 Replies

9. UNIX for Dummies Questions & Answers

ftp by date filter

i would be grateful if someone could supply me with a shell script which performed a ftp but only retrieved files which had a created date greater than a specific date - is this possible with ftp? many thanks mc (1 Reply)
Discussion started by: campbem
1 Replies

10. Shell Programming and Scripting

Shell Script for searching files with date as filter

Hi , Assume today's date is 10-May-2002. I want to get a list of files which were last modified since 01-May-2002. If I run the script after 5 days, it should still list me the files modified from 01-May-2002 till today. I also plan to pass the date 01-May-2002 as an argument to the shell script... (3 Replies)
Discussion started by: kanakaraj_s
3 Replies
Login or Register to Ask a Question