I've been using this to search an entire directory recursively for a specific phrase in my code (html, css, php, javascript, etc.):
Code:
find dir_name -type f -exec grep -l "phrase" {} \;
The problem is that it searches ALL files in the directory 'dir_name', even binary ones such as large JPEG images.
Hi,
I'm trying to search for a particular phrase in a large number of PDFs in a particular directory.
What I've done so far only prints out the line, but I haven't been able to display in which file the phrase appears.
Code:
find .
I have a directory with 1,242,276 plain text files on my external hard drive. They are totally unorganized with meaningless numbers as their file names. The reason for that is because they were recovered by some recovery software after accidentally emptying a partition a while ago.
I am now under that directory and want to search for a word "polyhedron" among the content of all the files.
I've found out this is not as easy as I thought at first:on the other OS we know,all text files end with the .txt extension,which makes searching for them quite straightforward-no such thing on Linux,so how can I search for text files in a directory where they may be (and actually are) intermixed with all kinds of other files ?
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 .
I want to go recursively through a directory and search for specific content in all files. The content should then be replaced if found. With a single line I would make something like this:
find . -type f -exec sed -i -e 's@code2replace@@g' {} \;
It sometimes worked and sometimes not (not sufficient hard drive space ...). Now I would need something for a multine replacement.
I found an SO called using Find/Grep to search files between specific time of day
Based on that and a Unix SE called Grep command to find files containing text string and move them I ended up with:
find . -type f -mtime -20 | grep -v -e " \(0[012345]\|18\|19\|2[0123]\)" | xargs mv -t daytime/
But it's moving ALL the files.
Hi,
I discovered the following single-line script works very well to cp a large number of files from a source directory to a destination directory while avoiding the "argument list too large" error:
# cpmany - copy large number of files
# Takes two parameters - source dir, destination dir
# Copies ALL regular files from source dir to destination dir
# Does not traverse subdirectories
I have this command in my bashrc
mygrep() {
find /var/www/project1 -name '*.py' -o -name '*.html' -o -name '*.js' -type f | xargs grep -Hn "$1" ;
}
i want few modification
I don't want to hardcode the path but wherever i execute that , it should search from the directory where i am executing the comand
It should get the directory to exclude from the files like ~/find-excludes.txt