Need to search for keywords within files modified at a certain time


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Need to search for keywords within files modified at a certain time
# 8  
Old 08-29-2012
I have no idea why you post code is so different from the good advice in post #2.

Why does your failing command contain "echo" when the original advice contained "grep". Please post the full script and any error messages.


Ps. It is very bad practice to string commands together with semi-colons. It makes the code virtually unreadable.

Last edited by methyl; 08-29-2012 at 08:15 PM..
# 9  
Old 08-30-2012
Quote:
Originally Posted by methyl
Why does your failing command contain "echo" when the original advice contained "grep".
Because I told him to, so I could see which files it was trying to match.
# 10  
Old 08-30-2012
Quote:
Originally Posted by virtual123
i just tried substituting echo for grep and it lists a whole bunch of files.
Yes... And do they happen to be the right files, or the wrong files?

If they are the wrong files, in what way are they wrong? Too old? Too new?
# 11  
Old 09-20-2012
They are not the right files, as they none of these files have the keyword I am searching for. I tried to break up your command for testing
$ touch 201209200700 /tmp/dummy1
$ touch 201209200800 /tmp/dummy2
$ find . \( -newer /tmp/dummy1 -a ! -newer /tmp/dummy2 \)

This should list all files modified after 7 am today and before 8 am today, correct?
but the output of the above commands is just one file and that was created at 10:42 am, which doesn't look right to me.
-rw-r----- 1 spprt 6590 Sep 20 10:42 data.dat

Any thoughts? Please assist.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search files in directory for keywords using bash

I have ~100 text files in a directory that I am trying to parse and output to a new file. I am looking for the words chr,start,stop,ref,alt in each of the files. Those fields should appear somewhere in those files. The first two fields of each new set of rows is also printed. Since this is on a... (7 Replies)
Discussion started by: cmccabe
7 Replies

2. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

3. Emergency UNIX and Linux Support

Is there any way to set the files modified date and stamp to last modifies time?

Actually i did modification in a file on server by mistake, now its showing current time stamp, is there any way to set the files modified date and stamp to last modifies time. Please advice here.Thanks in advance.:b: (7 Replies)
Discussion started by: saluja.deepak
7 Replies

4. Shell Programming and Scripting

Search a file with keywords

Hi All I have a file of format asdf asf first sec endi asdk rt 123 ferf dfg ijglkp (7 Replies)
Discussion started by: mailabdulbari
7 Replies

5. UNIX for Advanced & Expert Users

Find and store files based on FileName and Modified Time

Hi, I am currently using the following command: files=(ls enuCPU??.????.exp ntuCPU??.????.exp) I need to now change the commmand to store the file names of files that have been modified before datetime equal to say '02/16/2008 20:30:00' What could I use? (2 Replies)
Discussion started by: edisonantus
2 Replies

6. UNIX for Dummies Questions & Answers

deleting files based on file name and modified time

Hi, I have some log files created in the following fashion Ex: file name modified date 1) s.log1 01-jan-08 2) s.log2 02-jan-08 3) s.log3 03-jan-08 4) s.log4 04-jan-08 Now I want to have the latest 2 logs and delete the others. Can you tell me the one liner /... (1 Reply)
Discussion started by: ammu
1 Replies

7. Shell Programming and Scripting

Unzip files where modified time>05:00 ?

Hello :D I am on the shell prompt in a directory, with couple of zip files in it. How can I unzip '*.zip' where modified time > 05:00 ...please help Regards SunnyK (3 Replies)
Discussion started by: SunnyK
3 Replies

8. Solaris

Finding list of modified files for a particular time duration

Hi , I am trying to find out the List of files modified or added aftter installation of any component on SUN solaris box . But i am not able to do it using ls or find command . Can somebody help me out ? Thanks Sanjay Gupta (2 Replies)
Discussion started by: sanajyg_mnit
2 Replies

9. Shell Programming and Scripting

Finding out the last modified time for files

I need to find out the last modified time for the files which are older than 6 months. If I use ls -l, the files which are older than 6 months, I am just getting the day, month and year instead of exact time. I am using Korn shell, and SUN OS. Thanks in Advance, Kiran (3 Replies)
Discussion started by: kumariak
3 Replies

10. UNIX for Dummies Questions & Answers

Checking modified time of files

My problem is with the find command. After looking through the forum I've got - find . -mtime 2 -name "*" which gives me a list of all the files modified in the last 2 days. How do I change this to list files modified in the last 2 hours? Sorry if this question is already on the forum... (4 Replies)
Discussion started by: am97395331
4 Replies
Login or Register to Ask a Question