Execute a command, passing constructed argument list(s). The arguments are typically a long list of filenames (generated by ls or find) that are passed to xargs via a pipe.

learn more… | top users | synonyms

1
vote
2answers
52 views

I need to augment my output to include cat-ing a file in this Bash script

I have a script querying a remote server based on user input and looks for the last modified date of a file. It works, however, contained in the file is a string that I need to have displayed as well ...
-3
votes
2answers
62 views

Remove all files in directory except last 20

I have question why is my cmd for "removing all files in directory except last 20" not working within cron but in command prompt yes. * * * * * ls -1tr /home/testusr/test | head -n -20 | xargs -d ...
2
votes
1answer
45 views

Tracking progress with xargs

I'm using xargs to execute a command on a set of input parameters something like this: cat <someinput> | xargs -n 1 -P 5 <somecmd> The input file is really long and take a long time to ...
1
vote
2answers
86 views

Redirect to stdin instead of argument when using xargs [closed]

for exmaple, using the command cat foo.txt | xargs -I{} -n 1 -P 1 sh -c "echo {} | echo" The foo.txt contains two lines foo bar The above command print nothing.
1
vote
2answers
155 views

find: how to not have errors (stderr) when no files exists

I have a custom script which gzip log files when they are one day old. In my script all errors (stderr) are logged to a file and at the end of the script I use this file to know if its execution was ...
0
votes
1answer
62 views

How to process a space delimited environment variable with xargs

I am trying to execute a long running process multiple times in parallel. The parameter for each execution of the process is stored in a space separated environment variable. Here is a contrived ...
1
vote
2answers
96 views

xargs “too long argument list”

I want to do something like this: cat 5.txt | xargs -0 openssl prime but xargs is saying that argument list is too long Edit: cat 3.txt | xargs -n 1 openssl prime | wc -l works, thanks
0
votes
2answers
137 views

xargs remove file name containing $

I am using xargs to remove files from remote server. xargs -a /var/log/del.log -i -exec ssh root@abc.com 'rm -rf "{}"' del.log contains path of the files which are deleted on local server and I ...
0
votes
3answers
121 views

join xargs' output by newlines

I want to join output of the xargs output by new lines. I do this: find . -name '*.txt' | xargs -n 1 iconv -f UTF-16 | ...other-commands... I take one file at a time and convert it to UTF-8 (the ...
0
votes
1answer
190 views

how to wrap the command1 return strings with single/double quotation marks (\'or\") to feed to the next command2? [closed]

For example, I want to use mplayer to play the music of several dirs, type like this in bash: $find './l_music/La Scala Concert 03 03 03' './l_music/Echoes The Einaudi Collection' ...
1
vote
4answers
1k views

Cross-platform, human-readable, du on root partition that truly ignores other filesystems

Edit 09/20/2012 I made this way too complicated before. I believe that these commands are actually the simpler way, while still formatting everything nicely. RHEL 5 du -x / | sort -n |cut ...
2
votes
1answer
201 views

Xargs and bash script

The script works fine when executed manually but I recived the folloing error while it's run as a cron job: xargs: postsuper: No such file or directory #!/bin/bash mailgueue=$(mailq | awk ...
1
vote
1answer
61 views

How can I run hunspell on a list of files with xargs?

When I run find . -name "*.html" | xargs hunspell hunspell displays the first file with an spelling error, but won't accept input. I have to ctrl-c to kill it. What causes this? Is there a way ...
0
votes
1answer
222 views

Reverse and modify copy file to all subfolders command, xargs

i found this online it copy file to every sub folder on the current dir for full tree depth find -maxdepth 1 -type d -print0 | xargs -0 -n1 cp -v .htaccess now would be nice if it could ask if ...
0
votes
2answers
55 views

Running expand on a set of files

I'm trying to run the expand shell command on all files found by a find command. I've tried -exec and xargs but both failed. Can anyone explain me why? I'm on a mac for the record. find . -name ...
2
votes
4answers
2k views

prevent xargs from quitting on error

According to the man page, xargs will quit if one of the execution lines exits with an error of 255: If any invocation of the command exits with a status of 255, xargs will stop immediately ...
0
votes
2answers
312 views

tar too slow when file doesn't exist!

I have a gigantic list of files on a text files. This list is passed to tar, like this: cat list.txt | xargs tar rvf archive.tar --ignore-failed-read The problem is that some files that are on the ...
0
votes
1answer
119 views

Backup to Tape using tar: How to add file details (time, date, size) to a TAR log?

What is the best way to make my tar log more informative? Cat'ing the log shows what was backed up, but tells nothing about the files last update or size. Eg: tar cvf /dev/st0 foo* > backup.log ...
5
votes
2answers
3k views

How can I handle spaces in file names when using xargs on find results?

One of my common practices is to perform greps on all files of a certain type, e.g., find all the HTML files that have the word "rumpus" in them. To do it, I use find /path/to -name "*.html" | xargs ...
2
votes
5answers
763 views

Find files containing a string on the whole filesystem

I need to find all the instances of a given string in the whole filesystem, because I don't remember in which configuration files, script or any other programs I put it and I need to update that ...
1
vote
3answers
827 views

chmod of 400,000 files inside multiple subdirectories?

Howdy... I'm looking to chmod 777 a whole bunch of files. Alternatively, since it's more secure, I could also settle for a chown www:www of these files to make them web accessible. Now, since I have ...
1
vote
1answer
1k views

SSH to server with xargs

I have a pretty easy problem I'm trying to resolve here. I'm constantly running the (host) command on domains, to get their IPs, then (host) again on those IPs to get their PTRs, then I'm SSHing to ...
3
votes
3answers
3k views

How can I download multiple files stored in a text file with curl and xargs?

How can I download multiple files stored in a text file with curl and xargs? This is my last trial: cat listfile.txt | xargs curl -O first file works well, but other files are just output to ...
12
votes
6answers
7k views

Newline-separated xargs

Is it possible to make xargs use only newline as separator? (in bash on Linux and OS X if that matters) I know -0 can be used, but it's PITA as not every command supports NUL-delimited output.
1
vote
2answers
171 views

Wondering why sed isn't working with xargs like I expected

I am wondering why the following command wouldn't work: sudo find . -name index.htm | xargs -0 sudo sed -i 's/pattern1/pattern2/g' When ran the two commands separately, they worked as expected, ...
4
votes
3answers
1k views

xargs --max-proc split output per proc?

I recently discovered the xargs --max-procs feature. How can split the output of the command by proc? Should I just create a mycommand --logfile $LOGFILE, or can I do it from xargs itself? An ...
2
votes
2answers
5k views

Apply multiple .patch files

I have a directory with .patch files, generated using diff. I would like to apply all those patches using patch -p1 to another directory. But patch takes only one file, unless I cat. What would the ...
3
votes
2answers
285 views

What does rm {} + do?

As in find -L /etc/ssl/certs/ -type l -exec rm {} + So it finds all broken symlinks and deletes them. But how exactly do I interpret the {} + part?
0
votes
5answers
2k views

How to recursively search and replace from command line on unix/linux system

So I want to change several files at one with one command. This is what I have so far: find -regex ".*\.ext$" | xargs grep -l searchText 2> /dev/null | xargs -i sed 's/searchText/replaceText/' ...
0
votes
2answers
376 views

Is the svn nightly commit script built to capture all possible scenarios?

I have a nightly svn commit script that should take into account all possible scenarios and commit new things to our svn repository. Basically I am running the following steps: svn status [path] to ...