I've been using this to search an entire directory recursively for a specific phrase in my code (html, css, php, javascript, etc.):
The problem is that it searches ALL files in the directory 'dir_name', even binary ones such as large JPEG images. With a directory also containing large number of images dispersed everywhere, it dramatically reduces the efficiency. Sometimes it takes very long to get a response.
Is there any parameter I can easily use to make it only search text files?
There is no find option for picking or excluding text files. By convention, JPEG files usually end in .jpgor.jpeg, but it is just a convention and even following convention it could be in uppercase or lowercase. If you know that the JPEG images in your file hierarchy all have the extension.jpg, you could exclude them from the search using:
Note also the+instead of\;at the end of the -exec primary. That will produce the same output, but will invoke grep many fewer times (which will significantly improve performance when processing lots of files).
If your source files all use common naming conventions you could restrict your search to just those files using something like:
where the...is replaced by other-o -name '*.ext'sequences specifying the rest of the filename extensions matching your set of source files.
I am working on a script to search for text.
read -p "Enter text to search for : " n1
grep $n1 /home/andy/bin/*.sh
It works, but if I backspace, it does this.
Enter text to search for : sset Master^
------ Post updated at 12:39 PM ------
My mistake is I used the left arrow key... (4 Replies)
Hello all,
this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction.
My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Hello All,
Can someone please help me out in creating the find command to search and delete files older than 1 days at a desired location.
Thanks in advance for your help. (3 Replies)
Hi Forum,
I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result.
cd $dir... (8 Replies)
The requirement here is i'm searching for a particular word from the log file between two time stamp.
The process for particular account will happen, so i need to see there is any error occurred in between before it completes. in the below code yyyyy and xxxxx are two unique fields. initially... (1 Reply)
Hi.
I would like to have experts help on below action.
I have text files in which page nubmers exists in form like
PAGE : 1
PAGE : 2
PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
Hi
i am having a group of *.csh files under parent directory. Now i want to search a particular pattern in these group of *.csh files(suppose i need to search a pattern ABC - proj ). Can anyone please tell me how to do it using find command.
Thanks in advance
sarbjit (4 Replies)
i need help with my script....
i am suppose to grab files within a certain date range
now i have done that already using the touch and find command (found them in other threads)
touch -d "$date_start" ./tmp1
touch -d "$date_end" ./tmp2
find "$data_location" -maxdepth 1 -newer ./tmp1 !... (6 Replies)
Hey Guyz I have a requirement something like this..
a part of file name, date of modification of that file and a text is entered as input.
like
Date : 080206 (MMDDYY format.)
filename : hotel_rates
text : Jim
now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)
In a CSH, i need to write a loop to seach continuously for text "Started" and then only exit from the loop when ever if finds that.
Can someone please suggest how we can write this
Thanks,
Sateesh (3 Replies)