1
vote
2answers
68 views

How do I search for a string in a group of files when some of those files contain spaces?

I'm running Mac 10.7.5. In a terminal, I'll use this command for finding files with strings find src/main -name "*" | xargs grep -i 'mystring' However when the files contain spaces, I'll get ...
0
votes
1answer
59 views

Why doesn't this xargs + grep combo work properly?

I have two files, team1.txt and team2.txt team1.txt =========== Alex Bob Charlie David team2.txt =========== Alex Charlie Benjamin Zed Noah I want to output the people who are in both team1 ...
0
votes
2answers
444 views

xargs and cp: find-style “{}+” multiple expansion?

I'd like to copy a group of files to destination folder. But without needing to spawn a new instance of cp for each operation. The arg format for cp seems to be: cp src_file1 src_file2 src_file3 ...
1
vote
6answers
4k 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
1answer
691 views

Using a Linux/Unix terminal to copy many files to a new location

I'm trying to use the a Linux terminal to copy many files to a new location. I tired the command: sudo locate -i *file_I_want* | xargs cp $1 /place_I_want_everything_copied_to/ Which, gives an ...
0
votes
1answer
73 views

How do I grep for foo && !bar?

I want to output all the lines in my source code which contain the string foo but don't contain the string bar. I tried this: find . -name "*.[hc]pp" | xargs grep -n foo | grep -x bar However ...
1
vote
2answers
2k views

How to feed grep output into scp?

I have a file where each line is a file name. Content of the file: file1 file2 file3 ... I then run a grep command to get a subset of the list of the file names. How do I feed the output of the ...
1
vote
3answers
380 views

Expanding globs in xargs

I have a directory like this mkdir test cd test touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt I want to run some command such as ls on certain types of files in the directory and have the * ...
4
votes
3answers
2k views

Escape files output for compatibilty with 'xargs'

I have this command: find $1 | xargs touch But files with ' characters in their names fail with "xargs: unmatched single quote", and I guess other special characters would cause the same problem. ...
3
votes
2answers
2k views

using xargs to cd to a directory

Feeling like an idiot right now. Why does this not work? echo "/some/directory/path" | xargs -n1 cd
1
vote
4answers
156 views

printing matching lines when greping all files in a directory

I'm searching within Java files for some occurrence of a phrase: find . -name '*.java' | xargs grep -l 'string' How do I change this command to print to the shell all of the lines which contain a ...