getting timestamp of a file and if it was accessed today then finding a line in it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting getting timestamp of a file and if it was accessed today then finding a line in it
# 1  
Old 02-25-2012
getting timestamp of a file and if it was accessed today then finding a line in it

i have my files and the variables value extracted from db is taken as

in1=slot0312
in2=best
in3=it is :veryliong/fine

as varibles..

i have a folder stuctures in my unix machine as :

/2011/hand_sl0312/best/HOD/file1.txt
/2011/hand_sl0312/happy/HOD/file1.txt
/2012/hand_sl0312/best/HOD/file1.txt
/2012/hand_sl0312/happy/HOD/file1.txt
/2012/hand_sl0612/normal/HOD/file1.txt
/2012/hand_sl0612/best/HOD/file1.txt

llly many more.

in2 variable values can be any of the folders names from folder /2012/hand_sl0312/ in machine extracted from db or /2012/hand_sl0612/ or /2012/hand_RI12/ ,etc

in1 values are all from folder /2012/ or /2013/ but here format remains hand_sl0312. so values for in1 is like sl0312,sl0612 , etc..if in1 value is sl0312 then it is to be searched in folder /2012/hand_sl0312/ and if in2 value is "best" as above eg then it is to be searched in /2012/hand_sl0312/best and in3 value is to find in that folder based on access of file in folder /2012/hand_sl0312/best/HOD/file1.txt .. i.e if file1.txt is acessed that day then find value in3 in that file . if present . then no need to output .if not present then it should be written in other file for output..

but this three values are compared by taking all at a time ..so for above example.


so in this example
in1=slot0312
in2=best
in3=it is :veryliong/fine

the file /2012/hand_sl0312/best/HOD/file1.txt will be searched for in3 variable value i.e "it is :veryliong/fine"..

if it would have been eg as
in1=slot0612
in2=normal
in3=alwaysdoing:verylioniseong/fine

then the file /2012/hand_sl0612/normal/HOD/file1.txt (found from all variables) should be checked if it was accessed same day then only for value in3=alwaysdoing:verylioniseong/fine will be searched


the folder /2012/ or /2011/ or /2013/ , etc should be choosen depending on value in1, i.e suppose value of in1=slot0612 then folder /2012/ should be choosen and if it conatains in1=slot0311 then folder /2011/ should be choosen . this folder is choosen from last two digits value from in1 as in1=slot0312 so last two digit is 12 so choose 2012 , iif it would be 11 then choose 2011 and then proceed..


this values in1, in2, in3 are extracted from database...so having a huge dataB..
unix code for this comparison is needed...plz help

Last edited by rajniman; 02-25-2012 at 03:08 PM..
# 2  
Old 02-27-2012
i have extracted this variables from a database in while loop. so comparisn of this type is needed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error when connecting to remote server to find files with timestamp today's day

I am connecting to remote server and try to check if files with timestamp as Today's day are on the directory. Below is my code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly; Today=`date +%Y%m%d`; if ;then echo "We... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

Finding the maximum timestamp in a folder

I've the files in a directory in the following format having date +%Y%m%d%H YR_MNTH_2013061205 YR_MNTH_2013060107 and i need the latest file i.e; YR_MNTH_2013061205 to be moved to another folder #!/bin/ksh # Ksh 88 Version for test_time in YR* do --- done How can i achieve that !... (2 Replies)
Discussion started by: smile689
2 Replies

3. UNIX for Dummies Questions & Answers

Finding the modified timestamp of files from the piped output of du command

Version Info +++++++++++++++ RHEL 5.4 Since ls command lists file sizes in Bytes which can be long I use du command like below. I have run the du command for the below files as shown below. But I want pipe this output to ls command just to see the modified timestamp for these files. ... (7 Replies)
Discussion started by: kraljic
7 Replies

4. Shell Programming and Scripting

Help with finding last line of file: if statement depending on that line.

Good morning, My first time actually posting in this forum, though I have used this forum to help with numerous projects. I am trying to figure out why my if statement does not work. I have a file where a line is inputted every 15 seconds. I want this if statement to check what the last line... (3 Replies)
Discussion started by: Shanrunt
3 Replies

5. Shell Programming and Scripting

Appending unix timestamp to every line of a statistical file

I have a statistical file populating every minute as below: 2011-11-11-1108 1955 891 2011-11-11-1109 2270 1049 2011-11-11-1110 1930 904 2011-11-11-1111 2030 931 2011-11-11-1112 1944 900 2011-11-11-1113 1922 875 Instead of having the date and time in the given format (2011-11-11-1113) I... (10 Replies)
Discussion started by: thinktank
10 Replies

6. UNIX for Advanced & Expert Users

Finding user accounts not accessed for a specific number of days

Hi all, Recently I came across a challenge of finding the user accounts lying around on servers and not being used so much. Our client has hundreds of AIX, RedHat, and Solaris servers. For AIX, I have made a script which uses lsuser and a little bit of sed and awk to show the user accounts... (7 Replies)
Discussion started by: admin_xor
7 Replies

7. Shell Programming and Scripting

finding the line number of a particular line in a file

Hi Frnds, I need to find the line number of a particular line in a file and store that line number to a variable. if a file named myfile contains following look at the sun look at the moon look at the star look at the ocean i need to get the line number of the line 'look at the... (3 Replies)
Discussion started by: mvignesh
3 Replies

8. UNIX for Dummies Questions & Answers

Need help finding a file where a pattern exists and the file has a timestamp

So, I know how to do some of this stuff on an individual level, but I'm drawing a blank as to how to put it all together. I have a pattern that I'm looking for in a log file. The log file I know came in yesterday, so I want to limit the search to that day's listing of files. How would I do... (5 Replies)
Discussion started by: kontrol
5 Replies

9. Shell Programming and Scripting

Find files older then today & display with timestamp info

Small query- I want to do some operation on all the files older then today. Before I do that operation, i want to verify if the command works properly or not. Surprisingly, the command below returns me file, which are created today - find /mrk_archive/PG/ftp/incomming/gbs/2008 -type f... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

10. Shell Programming and Scripting

finding latest file having timestamp on it.....

Hi guys, I have a directory in UNIX having files with the below format, i need to pickup the latest file having recent timestamp embedded on it, then need to rename it to a standard file name. Below is the file format: filename_yyyymmdd.csv, i need to pick the latest and move it with the... (1 Reply)
Discussion started by: kaushik25
1 Replies
Login or Register to Ask a Question