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
1answer
24 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 ...
1
vote
1answer
22 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 ...
0
votes
1answer
113 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 ...
4
votes
2answers
2k views

Feeding Multiline STDIN Input to Command

I have a script that outputs git repository SSH URLs, like this: git@example.com:namespace/project.git git@example.com:another_namespace/some_other_project.git I want to run the command git clone (...
0
votes
0answers
65 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 ...
0
votes
1answer
1k 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 ...
-1
votes
3answers
55 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?
1
vote
1answer
269 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 #...
0
votes
1answer
1k 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 ...
1
vote
2answers
124 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
1k 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 '\...
11
votes
3answers
3k 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 ...
12
votes
2answers
4k 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
884 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 ...
1
vote
1answer
1k 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 ...
2
votes
2answers
2k 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
518 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
874 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
485 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/...
1
vote
4answers
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\...
2
votes
1answer
716 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-...
1
vote
1answer
102 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
325 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
102 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 "*....
24
votes
6answers
20k 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 ...
0
votes
2answers
731 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
278 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 ...
27
votes
3answers
19k 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
4k 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
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 ...
1
vote
1answer
4k 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 ...
7
votes
3answers
11k 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.
40
votes
5answers
34k 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
191 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
2k 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 ...
7
votes
4answers
20k 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
4k 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
6answers
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/' >...
0
votes
2answers
467 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 ...