Sponsored Content
Top Forums UNIX for Advanced & Expert Users Need to search for keywords within files modified at a certain time Post 302693663 by virtual123 on Wednesday 29th of August 2012 12:28:04 PM
Old 08-29-2012
Need to search for keywords within files modified at a certain time

I have a huge list of files in an Unix directory (around 10000 files).

I need to be able to search for a certain keyword only within files that are modified between certain date and time, say for e.g 2012-08-20 12:30 to 2012-08-20 12:40

Can someone let me know what would be the fastest way to perform this search?

I tried using find . -exec grep -l "searchword" {} \; and it is taking a lot of time to perform the search as it searches within all the files in the directory.

I am not very much familiar with Unix.. Any help you could provide is greatly appreciated. Thanks!

Last edited by methyl; 08-29-2012 at 08:10 PM.. Reason: please use code tags
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
synclist(4)							   File Formats 						       synclist(4)

NAME
synclist - list of files to be synchronized when changing from one boot environment to another SYNOPSIS
/etc/lu/synclist DESCRIPTION
The synclist file lists files that will be synchronized when you switch from one boot environment (BE) to another. The file is part of the Live Upgrade feature of the Solaris Operating Environment. See live_upgrade(5) for an overview of the Live Upgrade software. The synclist file consists of a list of entries, with two fields per entry. The first field is a pathname, the second a keyword. The key- word can be one of OVERWRITE, APPEND, or PREPEND. The meanings of these keywords is described below. synclist accepts comments; a comment is indicated by a hash mark (#) in the first character position on a line. The way in which a file is updated is indicated by the keyword in the second field of its synclist entry. All of these operations occur upon the first boot of a newly activated BE. The keywords have the following semantics: OVERWRITE Overwrite the contents of a file with the contents of the file of the same name on the previously booted BE. Both directories and files can be specified for overwriting. If you specify a directory, every file in and beneath the listed directory is subject to being over- written. (Whether an individual file or directory is overwritten depends on the outcome of the comparison of file versions, described below.) Following an overwrite operation, a file on a new BE has the same date of creation, mode, and ownership as the file of the same name on the previously booted BE. APPEND Append the contents of a file on the previously booted BE to the contents of the file of the same name on the new BE. Use of APPEND allows for the possibility of duplicate entries in a file. You cannot use APPEND with directories. Following an append operation, a file on a new BE will have a different modified date and time from the same file on the previously booted BE. The mode and ownership will be the same between the two files. PREPEND Prepend the contents of a file on the previously booted BE to the contents of the file of the same name on the new BE. Use of PREPEND allows for the possibility of duplicate entries in a file. You cannot use PREPEND with directories. Following a prepend operation, a file on a new BE will have a different modified date and time from the same file on the previously booted BE. The mode and ownership will be the same between the two files. The second (keyword) field in a synclist entry can be empty, in which case the OVERWRITE action is assumed. In deciding when to update a file on a newly activated BE, Live Upgrade uses an algorithm illustrated in the table below. In the table, "old" refers to a BE relinquishing activated status; "new" refers to a newly activated BE. The "resulting state" occurs when the new BE is first booted. +------------------+--------------------+----------------------+ |State of File | State of File |Resulting State | | | | | |on Old BE | on New BE |on New BE | +------------------+--------------------+----------------------+ |Unchanged | Unchanged |Not updated | +------------------+--------------------+----------------------+ |Updated | Unchanged |Updated | +------------------+--------------------+----------------------+ |Unchanged | Updated |Not updated | +------------------+--------------------+----------------------+ |Updated | Updated |Conflict Indicated | +------------------+--------------------+----------------------+ When a file is updated on both an old and new BE, as shown in the last row of the table above, Live Upgrade reports the conflict and allows you to resolve it. Modify the contents of synclist with caution. Adding certain files to synclist might render a BE unbootable. Also, be careful in using the file-inclusion and -exclusion options in lucreate(1M) in conjunction with changes you might make in synclist. Again, you could render a system unbootable or end up with different results from what you expected. Switching BEs among different Solaris Operating Environment marketing releases (for example, from a Solaris 9 BE to a Solaris 2.6 BE) requires care. This is especially true if you make any modifications to synclist. For example, consider that the last-active BE contains Solaris 9 and you want to activate a BE that contains Solaris 2.6. In synclist in the Solaris 9 BE, you have added files that are present in Solaris 9 that are not present in Solaris 2.6 or that are no longer compatible with Solaris 2.6. If you forced synchronization with the luactivate(1M) -s option, the BE containing Solaris 2.6 might be synchronized with files that might not work under Solaris 2.6. EXAMPLES
Example 1: Updating the passwd File Consider the following scenario: 1. You create a BE, named first. 2. You create a new BE, named second, using first as the source. 3. You add a new user to first, thereby making an addition to the passwd file in first. 4. Using luactivate(1M), you activate second. At this point, Live Upgrade recognizes that the passwd file has been updated in first and not in second. 5. When you boot second for the first time, Live Upgrade, directed by the keyword OVERWRITE in synclist, copies passwd from first to sec- ond, overwriting the contents in the latter BE. The result described above obtains with any of the files associated with the OVERWRITE keyword in synclist. If the reverse had occurred-- you edited passwd on second and left passwd in first untouched--Live Upgrade would not have modified passwd in second when that BE was first booted. Example 2: Updating the /var/log/syslog File Consider the following scenario: 1. You create a BE, named first. 2. You create a new BE, named second, using first as the source. 3. Logging occurs, adding to the contents of /var/log/syslog in first. 4. Using luactivate(1M), you activate second. At this point, Live Upgrade recognizes that /var/log/syslog has been updated in first and not in second. 5. When you boot second for the first time, Live Upgrade, directed by the keyword APPEND in synclist, appends the contents of /var/log/syslog in first to the same file in second. The result described above obtains with any of the files associated with the APPEND keyword in synclist. If the reverse had occurred--you changed /var/log/syslog on second and left /var/log/syslog in first untouched--Live Upgrade would not have modified /var/log/syslog in sec- ond when that BE was first booted. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWluu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
luactivate(1M), lucreate(1M), lumake(1M), attributes(5), live_upgrade(5) SunOS 5.10 6 Aug 2003 synclist(4)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy