Skip to main content

Questions tagged [xargs]

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
23 views

find -print0 doesn't work piped to with xargs -0 when -or conditions are used

I'm trying to "grep" content from a list of files in current directory, matching either asp, html and htm extensions. I am also using cygwin, with: bash: 4.4.12(3)-release, findutils (find ...
Avenger's user avatar
  • 151
0 votes
0 answers
23 views

Rename folder file with stat output with bash and/or xargs

I have been trying to solve a little renaming problem. With bits and pieces taken from this site, man pages etc. Something fails but I cannot find out what... I have photo files in a folder, with ...
user3450564's user avatar
1 vote
2 answers
155 views

IPTables XARGS commands in shell script with no terminal

I am trying to configure an iptables rule that finds a matching IP and deletes as many instances it finds in a one liner. I have the command and it works in a traditional shell environment with path ...
Giancarlo D's user avatar
0 votes
1 answer
843 views

Failing string replacement in xargs command

I am trying to automatically create symlinks to directories and to replace a certain text string (foo) of the original name in the link name (bar). The name of the target directories may contain ...
Ric Treepusher's user avatar
0 votes
1 answer
549 views

What is the maximum value acceptable for xargs -P argument? [duplicate]

In this answer they mention 10 I did man xargs and couldn't find what's the maximum limit. Is it possible to send 10000 cURL requests per second? How about 50000 cURL requests per second? I mean all ...
sofs1's user avatar
  • 103
1 vote
1 answer
235 views

Linux cp specific files from a text list of files to subdirectories from a text list too?

I ask for your help to solve my problem because I am stuck. I explain the situation to you: I want to copy files whose path I have on a txt file in specific subdirectories specified in a second file (...
Carole31's user avatar
5 votes
1 answer
1k views

Finding all Public IPv4 and IPv6 addresses in a UNIX shell script

For monitoring purposes, I'd like to find out all public IPv4 and IPv6 addresses of a mobile-warrior UNIX box. Note that this is different from Finding the Public IP address in a shell script because ...
cnst's user avatar
  • 14.5k
2 votes
1 answer
827 views

Dropping the -print0 and -0 flags from find and xargs

Almost 10 years ago, I asked this question use SED recursively in linux? and got this useful command find . -type f -print0 | xargs -0 sed -i 's/regex_search_term/replace_term/g' I decided to learn ...
learningtech's user avatar
  • 7,659
0 votes
1 answer
63 views

capture process that keeps changing PID

i have the following: netstat -anp | grep ':36084 ' | grep CLOSE_WAIT | awk '{print $7}' | cut -d \/ -f1 | grep -oE "[[:digit:]]{1,}" this returns a process PID i want to inspect and find out more ...
khinester's user avatar
  • 213
1 vote
1 answer
146 views

Why is bzip2 -d running in parallel not fully utilizing cpu resource?

I have 1000 .bz2 files and a 48 core machine. So I decided to run bzip2 -d in parallel to speed up unzipping them. But what I found is that the utilization of cpu under top is very suboptimal. For ...
John Jiang's user avatar
0 votes
1 answer
353 views

Run GNU parallel commands in different folders

I'm trying to run commands in parallel. But these commands need to be run in different directories. How can I achieve this? Can I do something like this: parallel ::: 'cd platform1 && npm ...
masterforker's user avatar
4 votes
2 answers
7k views

Feeding Multiline STDIN Input to Command

I have a script that outputs git repository SSH URLs, like this: [email protected]:namespace/project.git [email protected]:another_namespace/some_other_project.git I want to run the command git clone (...
Robert Dundon's user avatar
0 votes
0 answers
85 views

linux copy directory over another directory and if the same rename older files appending the modification date-time

In Linux, I am wondering how one can copy (maybe some sort of merge) one directory over the second directory - which can have the same name - and if two file have the same name then rename whichever ...
fptstl's user avatar
  • 131
1 vote
1 answer
3k views

Bash script - wait for all xargs processes to be finished

I have written a small bash script for crawling an XML sitemap of URLs. It retrieves 5 URLs in parallel using xargs. Now I want an E-Mail to be sent when all URLs have been crawled, so it has to wait ...
Alex's user avatar
  • 322
-1 votes
3 answers
165 views

copy files, get file names from a list

I am using a command: xargs -a file_list.txt cp -t /path/to/dest but the filenames with whitespace get cut and therefore are not copied. what can be done?
Rami's user avatar
  • 1
1 vote
1 answer
473 views

Finding strings in files with relative path

I don't understand why this two commands don't provide the same result (the differrence is only relative vs. absolute path), can somebody explain it? annika /srv/www/pages/com.example.www/www/povruc #...
Jakub Petržílka's user avatar
0 votes
2 answers
3k views

How to git add list of files from git diff

I accidentally added a bunch of cache files into the repo. I've now removed them and now want to commit the change to the repo. So I tried to do the following, but git doesn't seem to like it: git ...
denormalizer's user avatar
1 vote
2 answers
190 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 ...
subt3xt's user avatar
  • 11
-3 votes
2 answers
2k 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 '\...
George_223907's user avatar
17 votes
3 answers
10k 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 ...
Utkarsh Sinha's user avatar
20 votes
2 answers
10k 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.
Ryan's user avatar
  • 6,171
1 vote
2 answers
1k 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 ...
daks's user avatar
  • 673
4 votes
3 answers
4k 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 ...
gordo911's user avatar
4 votes
2 answers
6k 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
asfsafsfsaf's user avatar
0 votes
2 answers
918 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 [email protected] 'rm -rf "{}"' del.log contains path of the files which are deleted on local server and I ...
user1993197's user avatar
0 votes
3 answers
2k 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 ...
Paul Kole's user avatar
0 votes
1 answer
514 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' './l_music/...
infantcoder's user avatar
1 vote
4 answers
3k 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 -d\...
nice_line's user avatar
  • 149
2 votes
1 answer
946 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 '/MAILER-...
HTF's user avatar
  • 3,238
1 vote
1 answer
147 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 ...
Don Branson's user avatar
0 votes
1 answer
394 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 ...
JohnA's user avatar
  • 101
0 votes
2 answers
149 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 "*....
ChrisR's user avatar
  • 262
42 votes
6 answers
44k 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 without ...
JDS's user avatar
  • 2,638
0 votes
2 answers
918 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 ...
gmuller's user avatar
  • 53
0 votes
1 answer
364 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 ...
rodfaria's user avatar
33 votes
3 answers
27k 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 ...
abeger's user avatar
  • 481
2 votes
5 answers
5k 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 ...
Fabio's user avatar
  • 1,299
1 vote
3 answers
2k 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 ...
Julian H. Lam's user avatar
1 vote
1 answer
6k 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 ...
JacobN's user avatar
  • 156
7 votes
3 answers
12k 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 stdout.
Eonil's user avatar
  • 10.9k
73 votes
6 answers
61k 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.
Kornel's user avatar
  • 1,185
1 vote
2 answers
456 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, ...
user avatar
4 votes
3 answers
3k 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 ...
Gregg Lind's user avatar
14 votes
5 answers
37k 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 ...
styts's user avatar
  • 265
6 votes
2 answers
10k 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?
yanchenko's user avatar
  • 289
0 votes
6 answers
3k 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/' >...
Keith Bentrup's user avatar
0 votes
2 answers
488 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 ...
Geo's user avatar
  • 3,101