now that the introduction about the system is done i can tell the problem, i do have a script that is on the bottom to show you how i do things right now but, question is if i have a leap in days or hours or anything between my $startdate and $enddate (the logs are created with timestamps for each 100 mb collected )value that i use to search for the files that i want to see in the directorie logs, then a problem comes because we can have logs that came like this :
and think on this what if i want to see logs from 2012_07_02 ??? and this can happen because if a sensor dont collect enough traffic for the 100 mb then he goona leaps the end date until it reachs the 100mb but, for this i'm thinking or if i can search for the last know file before the date i search for $startdate ? that would do the trick but i dont know how to do it right now i have this :
soo with that said can anyone give me a hand , i know some people use find like:
i just dont know how to combine that in my script in the right way or even to say in a simple if to search for the last file recorded before the $startdate.
Last edited by jim mcnamara; 11-09-2012 at 08:56 PM..
Reason: the else is the key for the solution that is were im stuck
What exactly are you looking for? Do you want to find files which are older than a particular file or you want to find it using name?
If you are looking for files older than your reference file (let's say ref_file) you can use this :
(! for not newer than or rather older than your reference file)
Moderator's Comments:
Please use code tags
Last edited by jim mcnamara; 11-09-2012 at 08:55 PM..
I understood the problem lays in the fact that a single file can span several days worth of data, such as
Quote:
You need a method to find appropriate file for a given date, if I am not mistaken.
I propose to use gawk capacity to manipulate dates and use unix epoch date form, which can be compared arithmetically.
1) convert given date/time to epoch form
2) go through files and for each extract start_time and end_time from the file name and using a mktime function convert both into the unix epoch time
3) if given_time >= start_time and given_time <= end_time then you got the file needed.
Note: I'm not sure if awk/nawk has mktime function, that is why emphasis on gawk.
I have two directories
Dir 1
/home/sid/release1
Dir 2
/home/sid/release2
I want to find the common files between the two directories
Dir 1 files
/home/sid/release1>ls -lrt
total 16
-rw-r--r-- 1 sid cool 0 Jun 19 12:53 File123
-rw-r--r-- 1 sid cool 0 Jun 19 12:53... (5 Replies)
Hello
I have user directories that contain /temp directory.
Example folders:
/user1/temp/
/user2/temp/
/user3/temp/
How can i loop over all user directories and find all files only in their /temp folder?
Thanks a lot for help! (3 Replies)
First I'm new to Linux and have used the find command pretty often but this is where I've hit a snag. I have a file that contains 3500 files that I want to find and then eventually copy to my own directory (these files are all on a shared directory at work atm).
Our work computer are huge and... (2 Replies)
Find all files in the current directory only excluding hidden directories and files.
For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided.
`find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
My git post-update has the following lines in it to make sure the permissions are set right:
find /usr/local/apache/htdocs -type d -print0 | xargs -0 chmod 755
find /usr/local/apache/htdocs -type f -print0 | xargs -0 chmod 644
chown -R apache:apache /usr/local/apache/htdocsThe only problem is... (5 Replies)
I have a task, I usually do manually, but with growing responsibilities I tend to forget to do this weekly, I want to write a script that automates this, but I cant seem to work it out in my head, I have the shell of it out, but need help, and you guys have helped me with EVERY problem I have... (5 Replies)
Hello,
I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall:
I regularly need to delete files from many directories.
A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Need to make a script, to remove all empty files and folders from current category.
It also should show the name... (2 Replies)
Can anyone see why the following command returns all files and not just the directories as specified?
find . -type d -exec ls -F {} \;
Also tried
find . -type d -name "*" -exec ls -F {} \;
find . -type d -name "*" -exec ls -F '{}' \; -print
Always returns all files :-\
OS is... (2 Replies)
Hello,
We have in a file a list of the path of files from one server.
We want to search if these files exist on another server , but the path on this new server isn't the same.
We want to use the command "awk" but there isn't the god way.
Example:
on server 1 in a file : listServer1.txt... (4 Replies)