Sponsored Content
Top Forums Shell Programming and Scripting How to recursively search for a list of keywords in a given directory? Post 302640379 by neelmani on Monday 14th of May 2012 04:19:32 PM
Old 05-14-2012
How to recursively search for a list of keywords in a given directory?

Hi all,
how to recursively search for a list of keywords in a given directory??

for example:
suppose i have kept all the keywords in a file called "procnamelist" (in separate line)
and i have to search recursively in a directory called "target/dir"

if i am not doing recursive search then the below command is working.
Code:
fgrep -if  procnamelist target/dir/*

but when i am using the below command for the recursive search, its throwing error as "bad option -r"
Code:
fgrep -rif  procnamelist target/dir/*

or
Code:
fgrep -Rif  procnamelist target/dir/*



not working.

please help .Smilie

Last edited by Franklin52; 05-14-2012 at 05:24 PM.. Reason: Please use code tags for data and code samples, thank you
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and replace words between two keywords

Hi, I have a file which contains the following : select * from test where test_id=1; select id from test1, test2 where test_id=1 and test_id=2; select * from test1, test2, test3 where test_id=4 and test2_id where in (select test2_id from test2); select id1, id2 from test ... (6 Replies)
Discussion started by: vrrajeeb
6 Replies

2. Shell Programming and Scripting

How to search for keywords in subsequent lines

Hi all, I am looking for a coomand to search for the keywords in susequenct lines. Keyword1 in a line and Keyword2 in the very next line. Once i found the combination ineed to print the lines with patterns and the line above and one below. I am giving an example here: Keywords are :ERROR and... (12 Replies)
Discussion started by: rdhanek
12 Replies

3. UNIX for Dummies Questions & Answers

Linux shortcutkey to search specific file from a list of directory?!

Hi, I'm the new user of linux/unix. Can I ask that anybody know how to use the linux/unix shortcut key to search a specific file from a list of directory? For example, I know the file name that I want to search. But I forget which directory or location is my desired file put.Got any shortcut... (7 Replies)
Discussion started by: patrick87
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

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... (10 Replies)
Discussion started by: virtual123
10 Replies

6. Shell Programming and Scripting

search between keywords and make a single line

have a very big file where need to format it like below example file: abcd today is great day; search keyword 'abcd' and append to it all words till we reach ; to make it a single line. output should look like. abcd today is great day; There are many occurrence of such... (2 Replies)
Discussion started by: giri4332
2 Replies

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

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

9. UNIX for Beginners Questions & Answers

Search strings from a file in files in a directory recursively; then print the string with a status

Hi All, I hope somebody would be able to help me. I would need to search a string coming from a file, example file.txt: dog cat goat horse fish For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
Discussion started by: kokoro
9 Replies
ODFFILESEARCH(1p)					User Contributed Perl Documentation					 ODFFILESEARCH(1p)

NAME
odffilesearch - File selection by keywords SYNOPSIS
odffilesearch -R "D:Documents*.odt" openoffice desktop XML produces the list of the ODF Text documents present in the given directory and its subdirectories, and containing the words "openoffice", "desktop" AND "XML" odffilesearch -command "rm -f %f" "*.ods *.odt" lost dismiss cancel executes the "rm -f filename" (i.e. deletes the file in a Unix system) for each ODT or ODS file present in the current directory and containing the words "lost", "dismiss" AND "cancel" USAGE
odffilesearch [-options] <file filter> <keyword list> DESCRIPTION
This utility allows the user to retrieve a list of files matching a given set of keywords or regular expressions. A file is selected when it contains, in its text and/or in its metadata (title, subject, keywords or description), all the given search strings. The selected files are echoed to the standard output (one file per line), so this utility can be used as a filter piping its results to another program. Alternatively, a given shell command can be launched by the script each time a file matches, allowing on-the-fly processing of the selected documents. The files filter may content one or more space-separated paths. Each path may content jokers. So it's possible to explore several directories and/or several filename patterns. All the arguments after the file filter are processed as search criteria. OPTIONS
-R -recursive include the subdirectories of each given search directory -verbose -trace -debug echo some processing comments -warnings activate the warning messages of the OpenOffice::OODoc API -log <file> like -verbose, but then messages are sent to the given file and don't pollute the standard output -result <file> -output <file> send the list of matching files to the given file and not to the standard output -criteria <file> get search criteria from a file (one per line); the loaded search keywords may be combined with additional criteria passed with the command line, if any. -command <command> -exec <command> execute a shell command for each matching file ; if the command string contains "%f", this substring is replaced with the name of the selected file ; if this option is provided, the selection list is not echoed to the standard output ; if -verbose is on, the value returned by the command is echoed -encoding <encoding> selects the user's character set ; this option is mandatory if one or more search criteria contain characters not belonging to the default character set perl v5.14.2 2008-05-04 ODFFILESEARCH(1p)
All times are GMT -4. The time now is 07:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy