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

3
votes
2answers
1k views

How to use wildcards in a xargs-command?

I've got a directory with numbered files, e.g. 1_foo.txt 2_bar.asc 13_test.png, and want to move them into individual directories (e.g. 1, 2 and 13) using as simple a bash command as possible. ...
1
vote
3answers
640 views

Create multiple files and name them from command line

I need to create 300 blank files and put them in a folder on my server then name them from a list in a txt file, I have SSH access, so is it possible to do this using command line?
0
votes
4answers
165 views

how to do grep in the man command of linux using xargs?

I want to grep into a manual of a particular command say man grep |grep 'insensitive'. One of friends told me that It can be done using xargs but I cant seem figure out how. I want to do it using ...
1
vote
3answers
600 views

Difference between xargs /bin/ls and exec ls?

Hi this may be a very newbie question, but why doesnt the xargs /bin/ls work in this case? I thought it was supposed to be faster? Also what are those /fd/3 directories? sh-3.2# find / -name 'GOALS*' ...
0
votes
2answers
228 views

find -print0 | xargs -0 grep not working as expected on Ubuntu 10.04

I've got a bit of a weird issue. If I run: find . -iname '*.php' -o -iname '*.pl' -o -iname '*.html' | xargs grep -i users I get a load of errors for filenames containing spaces, but also some ...
0
votes
2answers
589 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 ...
3
votes
1answer
1k views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
0
votes
3answers
310 views

Passing multiple sets of arguments to a command

instances contains several whitespace separated strings, as does snapshots. I want to run the command below, with each instance-snapshot pair. ec2-attach-volume --instance $instances --device ...
2
votes
3answers
346 views

Xargs string interpolation, not by inserting a space

I want to repeat touch ../template/filename where filename comes from find. I want xargs to apply the touch operation, but I dont want it to insert a space like it usually does which derives into: ...
2
votes
3answers
2k views

Replacement for xargs -d in osx

In Linux, you can use xargs -d, to quickly run the hostname command against four different servers with sequential names as follows: echo -n 1,2,3,4 |xargs -d, -I{} ssh root@www{}.example.com ...
3
votes
3answers
502 views

xargs argument redirection

This seems to be a trivial problem but the solution eludes me ever so cautiously. I want to clear out many text files; log files. Reason? To save on disk space. With one text file, this is as ...
0
votes
1answer
183 views

Control mplayer ran by xargs

I feed mplayer with file list from another command: beet ls somequery -p | xargs -d '\n' mplayer When invoked this way, mplayer doesn't react on any standard keys, all I can do is to C-c interrupt ...
1
vote
2answers
124 views

Issue using xargs in Linux

I am attempting to pipe the output from youtube-dl to xargs as I would like to name the downloaded file with the title extracted from the first command. however am having trouble doing so. The command ...
0
votes
3answers
4k views

Using xargs with mv and mkdir command in Linux

I am attempting to create a directory using the command mkdir. However, I would like to move a subset of files into that directory. I understand I can use xargs, however my attempts have failed. For ...
1
vote
2answers
527 views

xargs split incoming line

I have a file with two columns separated by spaces like this: potato 5 apple 7 pretzel 9 I want to issue a command on each line like this: cmd -f potato -n 5 cmd -f apple -n 7 cmd -f pretzel -n 9 ...
1
vote
6answers
7k 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
2k views

Executing lines of a file with xargs, using stdout redirection

I have a file that has lines that look like this: "http://api.domain.com/path/to/resource?format=json" > output.xml and I execute the following from my command line: cat file | xargs -L 1 -I {} ...
1
vote
1answer
767 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
2answers
157 views

flexible number of agruments with xargs

Is it possible to specify the number of arguments that xargs takes without doing it explicitly with -n option, but implicitly with a delimiter, so that the single parameters would be delimited with a ...
9
votes
7answers
6k views

How can I use two parameters at once with xargs?

I need to convert videos but I don't know where are they, so I need to find them. How can I give the result and an output file name to ffmpeg with xargs ? I already find out that I can construct the ...
5
votes
2answers
5k views

using John the Ripper to recover RAR password

Testing John the Ripper in Mac OS X as a RAR password recovery solution, but xargs gives me an error: john --incremental:all --stdout | xargs -I jtr unrar e -pjtr -inul test2.rar | grep 100% xargs: ...
1
vote
3answers
1k views

Run xargs on the first word on a line

Is there a way to run xargs on only the first argument of a line? So if my input is the default output from a grep, like this: ./file1 "matching string" ./file2 "matching 2" What I want ...
1
vote
2answers
302 views

xargs touch followed by second command

I am randomly selecting files from a directory that I want to process, and I want to apply the touch command to them so that I know the last one that's been visualized, then apply the visualization ...
0
votes
1answer
75 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 ...
5
votes
1answer
4k views

Create symlinks recursively for a whole tree

I am seeking for a command that would re-create a whole tree of files in a different directory. I would prefer to have all symlinks absolute. Can I do that with a find and xargs? ;-)
3
votes
3answers
1k views

combining sed with xargs to obtain a source and output file name

I have a situation where I have some input files like this: M2U0001.MPG M2U0180.MPG And I want to run a command (in a bash shell) on each similarly named file in the directory. I'd like the ...
1
vote
2answers
742 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 | ...
1
vote
2answers
1k views

Remove all except one file and directory at path

I need to remove all the files in a directory except for one file and one folder. Up to the grep I can output the correct list of items I want to remove but when i add xags, nothing is deleted. this ...
0
votes
1answer
307 views

find xargs and curl give an error with -C- option

This command works fine find ~/mypath -name *.fstq -print|xargs curl -u sdd:dsdsd ftp://ftp.dsdd.nsdh.com/sdsds/ -T but when I add find ~/mypath -name *.fstq -print|xargs curl -C- -u sdd:dsdsd ...
0
votes
2answers
290 views

Efficiently stripe incoming one-word lines onto columns?

Consider a stream of one-word lines such as the stdout of $ echo foo bar baz quux xyxxy thud | tr ' ' '\n' foo bar baz quux xyxxy thud I say "one-word" to indicate there is no whitespace other than ...
2
votes
2answers
178 views

Can I simulate ack by using grep with the right combination of options?

I have ack-grep installed on my local machine, and find it indispensable for quickly 'acking' through a codebase when debugging. However, on my cheap shared hosting, there is no ack-grep. One of the ...
3
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
3k 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
110 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 | ...
1
vote
3answers
530 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 ...
7
votes
2answers
379 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
782 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 ?
5
votes
3answers
2k 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
4k 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
3k 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
416 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
2k 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?
6
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
1answer
685 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 ...
3
votes
3answers
10k 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?
5
votes
2answers
4k 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 ...
6
votes
3answers
11k 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 ...