My desired outcome is the following: to recursively search a directory looking for a given string in all found files. The following command is my usual port of call:
find ./ | xargs grep -ns 'foobar'
However, when foobar has quotes the command fails and gives me a > prompt in the shell.
Hi All
I'm having a problem grep'ing files for a certain string on my server. The command I'm using is:
find .
Hi,
I have used this
Code:
find .
I have a malware on my server.
So I've figured out how to find all that malicious files
grep -r --include*.php "Some String from files" .
That seems work fine!
but how to delete them?
I've tried using xargs
grep -r --include=*.php "FilesMan" .
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.
I'm trying to find all files that are of a certain type and do not contain a certain string. I am trying to go about it by piping find to grep -v
example:
find -type f -name '*.java' | xargs grep -v "something something"
This does not seem to work. It seems to be just returning all the files that the find command found.
I have a unix command in a variable, it looks like this:
cmd="find /path/to/webpage -type f | grep -v .svn | xargs grep $@"
`$cmd`
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
When I try to execute the command $cmd in a bash script, it won't work, however, when I copy and paste the exact same command, it does work.
Hello,
Im using this unix command(in a php file) to remove a certain string and then remove the whitespace left by that string. Unofrtunately in many cases, the files get completely erased.
Is there a workaround?
Hi,
I'm testing nginx-cache-purge and notice that grep searches all file content, and since the cache key is in the second line I would like to limit grep searching.
This is the script I'm using:
github.com/perusio/nginx-cache-purge
The line I would like to change and limit grep search to the Second line is:
Code:
find $2 - maxdepth 1 - type d | xargs - P $max_ pa ralle l - n 1