utility in Unix-like operating systems for passing large numbers of arguments to programs that can only take a small number of arguments

learn more… | top users | synonyms

4
votes
3answers
3k views

How can I grep in source files for some text?

At the moment I'm using two commands, I'm sure there must be a better way... wim@wim-acer:~/ffmpeg$ find . -name "*.h" -print0 | xargs -0 grep -i invalid\ preset wim@wim-acer:~/ffmpeg$ find . -name ...
1
vote
2answers
4k 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 ...
0
votes
2answers
124 views

Multiple find by xargs

I have a problem; 1) I'm using find command to find directories; 2) I need to execute another find command in previously found directories. I'want something like this find . -type d -not -name bad | ...
2
votes
3answers
845 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
4answers
4k views

What is a Linux command to find files containing some strings but not another?

I'm trying to search a lot of XML files for certain strings but not other strings, and I'm having trouble putting a command together to do it. I only want it to list the file names that match the ...
8
votes
2answers
436 views

Xargs and Wget stops working after an hour

Running script with Cygwin on Windows XP with Dual Core and 4GB Ram cat url_list.txt | xargs -P50 wget -i I am trying to trawl through 4GB of URL to download (approx 43 Million) Works okay for ...
0
votes
2answers
1k views

find Argument list too long

I want to search in many many files for a string. I used find /archive/* -print0 | xargs -0 grep 'robert' -sl Is there a simple method to do it ?
6
votes
3answers
3k views

How to escape file 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. ...
0
votes
1answer
6k 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 ...
5
votes
1answer
5k views

xargs with multiple commands

I'm trying to execute a sequence of commands on a list of files one by one. I was wondering if it is possible to use xargs something on the lines of ls *.txt | xargs -n 1 -I {} cat {} | grep foo > ...
14
votes
5answers
4k views

How to run sed on over 10 million files in a directory?

I have a directory that has 10144911 files in it. So far I've tried the following: for f in ls; do sed -i -e 's/blah/blee/g' $f; done Crashed my shell, the ls is in a tilda but i can't figure out ...
1
vote
2answers
464 views

Passing the output of the last command to sed as an argument

Basically, I'm wanting to automate adding something to xorg.conf in the right place, I've used some commands to get the line number of the line I want to manipulate, but I'm not really sure how to go ...
1
vote
4answers
2k views

find with xargs

cat fileNames.txt | xargs find . -name I expect the above command to find the path of every fileName in fileNames.txt, but this command produces no output. Why?
4
votes
2answers
3k views

rsync N newest files in a directory

What would be the easiest way to go about rsyncing the n newest files in a directory to a remote server?
8
votes
2answers
3k 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
1answer
893 views

How to use xargs/find to execute on per file basis

I have some php scrits in a subfolder and want to run some of them (found by a regular expression) via command line. Here is what I have so far: find . -name email[^T]*\.php -print0 | xargs -0 -t ...
5
votes
3answers
16k views

ls -rt (How to list just THE LAST file? e.g. for: | xargs gnome-open)

e.g. directory containing jpeg files: how to easily open just the most recent jpeg in the current directory?
6
votes
2answers
5k views

Grep exits abnormally with code 123 when running rgrep on emacs

Greetings fellow Emacsers I'm running GNU Emacs 23.1.1 on "Ubuntu 10.04.1 LTS" and any search I perform using the built-in M-x rgrep on the standard Linux kernel source code (vanilla) ends ...
8
votes
4answers
15k views

Why does this not work? “ls *.txt | xargs cat > all.txt” (all files into single txt document)

Why does this not work? ls *.txt | xargs cat > all.txt (I want to join the contents of all text files into a single 'all.txt' file.) find with -exec should also work, but I would really like to ...
2
votes
3answers
2k views

find . -exec grep -l 'string' {} \; -print 2>/dev/null

it lists all files in "." that contain the string "string" but don't show dirs with permission denied. What would it be the equivalent of that but squeezing xargs in between?
1
vote
4answers
180 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 ...
4
votes
3answers
6k views

How do I use find to copy all found files to a new name in their same directories?

I've got a simple command that does almost what I want. The following will locate all files with a suffix of '_compressed.swf' and copy each into its same directory with a '.bak2' appended: find ...
0
votes
4answers
379 views

How do I execute find with GNU xargs to traverse a set of directories?

$ echo {a,b,c}.h d e.h |xargs -IA find A -name '*.h' find: `a.h b.h c.h d e.h': No such file or directory $ echo -e a.h\\nb.h c.h d e.h |xargs -IA find A -name '*.h' a.h find: `b.h c.h d e.h': No such ...
1
vote
3answers
3k views

Recursive move files of specific type to a specific path

In ~/my/path, I want to move all files that contain string "(J)" and have file type of ".foo" to ~/my/path/j I'm trying: [me ~/my/path]$ find -type f -name "*(J)*.foo" -print0 | xargs mv -0 j/ No ...
1
vote
3answers
2k views

xargs vs backtick

More silly questions from the Linux n00b. =D I'm curious about the performance ramifications of using xargs vs. backticks. For example, what's the different between: find ./ -name foo* | xargs rm ...
8
votes
4answers
10k views

find: -exec vs xargs (aka Why does “find | xargs basename” break?)

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via basename, but it did't work ...