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 have a list of file names as output of certain command.
I need to find each of these files in a given directory.
I tried following command:
ls -R /home/ABC/testDir/ | grep "\.java" | xargs find /home/ABC/someAnotherDir -iname
But it is giving me following error:
find: paths must precede expression: XYZ.java
What would be the right way to do it?
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.
What is the Linux command-line command that can identify such files?
AFAIK the find command (or grep) can only match a specific string inside the text file. But I want to match whole contents, i.e. I want to see which files match regular expression \0+, ignoring the line end character(s). Maybe the 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" .
find . -name '.htaccess' -print | xargs grep -il 'sound' | xargs -p sh -c ">{}"
Trying to find some .htaccess files on a host that've been compromised, grep them to make sure they are bad .htaccess (not all on server have been ruined) and blank them out.
All is working, except the last part. Tried many variations of echo > etc.
Hi,
I have created a shell script for Server Log Automation Process. I have used
find xargs grep command to search the string.
for Example,
Code:
find -name | xargs grep "816995225" > test.txt
.
Here my problem is,
We have lot of records and we want to grep the string 4-5 times.
In Windows, in a Git Bash shell, I want to detect files that have DOS-style line endings. I thought this command would work but it doesn't:
find dir -type f -print0 | xargs -0 grep -l '^M$'
It doesn't work, even files that don't have CR line endings match.
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.