1
vote
2answers
254 views

batch find/replace using sed or awk

In every file with filename matching pattern1 I want to search for lines which start with pattern2, and add some string in a new line above those matched lines. As a simple example suppose I'm ...
2
votes
3answers
668 views

sudo to kill output of ps, awk, xargs

I want to kill root owned processes containing foo in the process name sudo sh -c "ps aux | grep [f]oo | awk '{print $2}' | xargs kill -15" this command fail as awk and xargs are ignored. sudo sh ...
1
vote
6answers
5k views

Pipe output of awk to kill -9

I'm trying to kill any process that has to do with mysql. I'm piecing together a command, and so far, haven't come up with the right solution. One other consideration, is that the last process will ...
1
vote
2answers
669 views

File name with spaces piped to two xargs commands

I have a directory and many more subdirectories like the following - file with spaces.txt filewithsuperlonglines.txt ordinaryfile.txt binaryfile.bin The command - find . -type f -print0 | ...
0
votes
1answer
3k views

How to construct a grep command with a variable argument in bash?

I'm trying to do something like this in bash: grep ( date | awk '{print "2006-" $6}' ) /some/file/here But that syntax is incorrect. The goal is to grep /some/file/here for the pattern 2006-2011 ...