The following script is meant to output "vmstat" for example every 15 seconds, but for some reason it only does this if there's activity or when I kill the script, in other cases it just sits there.
#!/bin/bash
#!/bin/sh
ps -ef | grep -v grep | grep "vmstat 15" | awk '{ print $2 }' | xargs kill
ps -ef | grep -v grep | grep "iostat 15" | awk '{ print $2 }' | xargs kill
ps -ef | grep -v grep |
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.
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.
for example I type
ls -altr | grep "23 Dec"
so it will show files for 23 Dec only and I want to use grep for them, like
ls -altr | grep "23 Dec" | xargs grep -l "some_string"
but this doesn't work)
How to do that?
Hey everyone! I am determining the best method to do what the subject of this thread says. I only have pieces to the puzzle right now. Namely this:
grep -rl "expression" . | xargs open
(I should mention that the intention is to grep through many files containing the "expression" and return the files themselves for subsequent editing.)
and this:
...
Hi,
I would like to ask the following:
1) ls -l |grep test -> this will grep every "ls -l" output line
2) ls -1 |xargs grep test -> this will grep every single file with test
3) ls -1 |xargs echo -> this will echo directory list
4) ls -1 |echo -> this does nothing!!!
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.
#!/bin/bash
value=$(</var/www/sym_monitor/manthan.txt)
if [ "$value" == "true" ]; then
ps -ef|grep sym |grep -v grep |awk '{ print $2 }'|sudo xargs kill -9;
cd /var/www/symmetric-ds-3.1.6/bin;
sleep 30;
(sudo ./sym --port 8082 --server);
fi
I'm trying to run the above script every 10 mins using cron.