xargs is a command that executes another command and generates its arguments from stdin

learn more… | top users | synonyms

0
votes
1answer
28 views

Why does piping filenames into VIM break bash when I return to the shell?

I searched for a few files with find and I wanted to open all of them in tabs in Vim. So I tried this: find . | xargs fgrep -l myExpression | xargs vim -p This worked great, except when I was done ...
2
votes
3answers
98 views

How to make xargs handle spaces and special chars from cat?

I have a file that contains a list of names. i.e.: Long Name One (001) Long Name Two (201) Long Name Three (123) ... with spaces and some special characters. I wanted to make directories out of ...
1
vote
1answer
21 views

Pause (with read or similar) in xargs

I have a script that looks something like the following. find /path -type f | sed -re 'stuff' | xargs -Ix sh -c '{ echo "information about x" ./exe < x read }' My goal is to provide each ...
0
votes
2answers
39 views

Need to format 5 disks in parallel

I tried this xargs -p 5 -n1 mke2fs -t ext4 /dev/sd[d-p]1 and got this [/dev/mapper]# seq 1 15 | xargs -p 5 -n 1 mke2fs -t ext4 /dev/sd[b-p]1 5 -n 1 mke2fs -t ext4 /dev/sdb1 /dev/sdc1 /dev/sdd1 ...
-1
votes
2answers
50 views

xargs can't handle spaces in lines [closed]

Please, close this question. I'm so dumb. All the target files have been deleted. Of course, when I try to run any deletes again, the files aren't there to delete. Sorry to take your time, and thanks ...
2
votes
1answer
33 views

Using xargs for more commands

Is it possible to use find + xargs in order to invoke more than one command? I am trying to find all files whose size is greater than 100 chars. and less than 1000 chars , change their permissions and ...
1
vote
2answers
78 views

use find and grep to find lines that contain some string and don't contain other string from files

First, I try the following code find . -name "*.cfg" | xargs grep "good"|grep -v "^\#" In the current folder, I get the list with the file name's extension is "cfg". Then I want to search the ...
1
vote
2answers
40 views

xargs and line-by-line pipe

I have 3 files: a.txt, b.txt and c.txt I want to create 3 files: a.test, b.test and c.test containing the simple text "abracadabra". Basicaly, the point is to create the .test files for each .txt ...
0
votes
0answers
25 views

Using 'export' and 'xargs' in order to export environment variables from an separate file [duplicate]

I have a dev.env file that contains a number of environment variables. dev.env: APPLICATION_URL=http://localhost:8080 APPLICATION_DOCKER_IP=$(docker-machine ip default) ...
1
vote
2answers
41 views

tcpdump multiple pcaps w/ xargs

I am attempting to send multiple pcaps into an xargs loop in order to tcpdump them into a single file. These are 1GB PCAP files from Bro's Timemachine. There are examples online, but the only one I ...
0
votes
0answers
58 views

Difference between two almost same command

Please consider two following command: $ echo ls | xargs -I cmd echo cmd | source /dev/stdin $ echo ls | source /dev/stdin What's the difference between these commands? In my machine the result of ...
2
votes
1answer
56 views

passing variables from 'ls' to 'tar' via 'xargs'

I am trying to do something like ls -t | head -n 3 | xargs -I {} tar -cf t.tar {} to archive the 3 last modified files but it ends up running the tar command separately for each of the files and at ...
0
votes
1answer
45 views

quoting problem when piping find output into xargs [duplicate]

I have a directory with the following subdirectories, i.e. If I run $ tree -L 1 . ├── 2007-06-20_to_2008-10-01 ├── 2008-07-21_to_2008_08_12-Nokia 2mp ├── 2009-11-01_to_2011-01-10 - All iphone Pics ...
2
votes
1answer
116 views

How to copy recursively all files not older than 1 day?

How to copy recursively all files not older than 1 day? I first tried find . -amin -1440 | xargs cp /dest But it doesn't work because the items given to xargs should be positionned before the ...
1
vote
2answers
59 views

Combine xargs -I with sed

I want to use find to find certain files and then use xargs with cp and sed to move these files to another folder and rename them. I know how to do this in a loop, but that is not what I am looking ...
2
votes
3answers
101 views

curl page source from text file containing URLs

I have a text file containing up to 100 URLs. I am able to curl the page source from them using: cat /path/to/url.txt|xargs curl -o /path/to/output.txt This will download the page source for all of ...
1
vote
0answers
54 views

Chaining grep commands [duplicate]

I'd like to find all xml files containing 'foo', but not containing 'bar'. The command I've put together looks like this: find -iname "*.xml" -print0 | xargs -0 grep -FlisZ "foo" | xargs -0 grep ...
2
votes
2answers
65 views

How do I log xargs -0 rm?

I have a simple need to recursively find and delete files of a certain extension. So I have syntax that will find and remove the files and pipe them into xargs -0 rm, but I can't seem to create a log ...
2
votes
2answers
40 views

Find files with particular filename format, cat each one with a header file, and save result to original file for each such file [duplicate]

I have a bunch of html files and I want to cat them all (individually) with a header file (several lines at least in length), say header.txt. I'm almost there. I can cat each file with the header file ...
2
votes
5answers
177 views

How do I cat a file I got from stdin without xargs

In an effort to learn the shell better, and without always having to resort to xargs, I have been trying to discover any other ways to do: find . -name *.tcl | xargs -I{} cat {} xargs make it feel ...
1
vote
1answer
42 views

Sending a list (text file) of files and pathnames to xargs

I have a file that contains the paths of various files. files.txt : /path/to/file1.txt /path/to/file2.txt ... /path/to/fileN.txt I want to use it in a script to process the files. cat files.txt | ...
0
votes
2answers
49 views

find /mydir/tmp/*20151014* -print | xargs grep -l 'filesTransmitted=1' throws error

The command throws error: $ find /mydir/tmp/*20151014* -print | xargs grep -l 'filesTransmitted=1' bash: /usr/bin/find: The parameter or environment lists are too long. Is there any optimal command ...
0
votes
1answer
24 views

Using xargs to generate links

I have a file that looks like this: abc,123,x xabc,345,xy cabc,6234,ab abgc,12,yo jabc,9991,to I need to generate a list of links: http://www.mywebsite.com?param1=abc&param2=123&param3=x ...
0
votes
1answer
39 views

Problem using xargs to send commands to a screen from within a bash script

I'm currently writing a simple bash script for recording a streaming radio stream. The logistics of getting into work and getting set up mean that I miss about 30 minutes of my favourite breakfast ...
2
votes
0answers
37 views

How many ways are there to convert and pass stdin as command parameter?

I am new to Linux shell. I know that xargs can be used to accept stdin from a pipe and pass it to another command as parameter. Are there other ways to do so? Is there a list I can refer to? A ...
1
vote
0answers
29 views

What are the major differences between the Darwin/BSD and GNU versions of Findutils?

OS X comes with its own versions of find, locate, and xargs. GNU versions of these utilities are also available as part of GNU Findutils. What are the major differences between the two versions? Is ...
1
vote
1answer
97 views

Why does xargs -I imply -L 1

I've seen Why does 'find -exec cmd {} +' need to end in '{} +'? which explains why {} + has to be at the end of the -exec cmd(*), and now I'd like to know why GNU xargs reverts to one ...
2
votes
1answer
34 views

How to have a process queue in AIX like xargs with “--max-procs”?

Consider a simple processing queue like: cat list.txt | xargs -n1 -P20 process.sh (-P or --max-procs) How to have something like that in AIX ?
1
vote
2answers
50 views

xargs repl_str doesn't expand second placeholder

I would like to rename some files and exclude others into a directory. I tried find . -mindepth 1 -maxdepth 1 ! -name 000-default.conf ! -name default-ssl.conf -print0 | xargs -0 -I {} sudo mv -- {} ...
1
vote
1answer
18 views

copying sub-directories not containing a specific file into another directory

I have a directory named dir1 which has about 800 sub-directories named disp-001, disp-002, ... disp-800. I get the list of sub-directories that does not contain a file stdout based on solution given ...
4
votes
6answers
378 views

Is there a Unix command to quote input lines?

I am wondering if there is a filter command to quote input lines. So when piping: line number 1 line number 2 line number 3 to it, you get: "line number 1" "line number 2" "line number 3" I ...
0
votes
1answer
49 views

Find mails, pipe them to php and delete after

I have a script that saves to DB content of piped to it file. cat /mailpath/Maildir/cur/mailfile | php -q /scriptpath/mailPipe.php I need a shell script or oneliner to find all files in Maildir, ...
1
vote
1answer
72 views

zsh capture and pipe output to another command

I had the zsh script printf '%s\0' www/scripts6/lib/* | xargs -0 -I{} -P 50 babel {} > {} and it worked (i think.). But I needed to actually copy the files to the scripts directory instead of ...
2
votes
0answers
87 views

Why does this pipe not end when the las process dies (zombie)?

I have a script run and monitored by svscan/supervise. When the last luces-hf/run: #!/bin/bash set -v export http_proxy=[redacted] curl -N -s https://[redacted] |\ grep --line-buffered "event" | ...
3
votes
2answers
113 views

How to use `yes` with `xargs -p`?

Let's say I have ls | xargs -n1 -p rm, how do I use yes or yes n to automatically answer the questions generated by the -p flag? I tried yes n | (ls | xargs -n1 -p rm) but didn't work. P.S. I tried ...
0
votes
1answer
70 views

Command does not execute properly on remote server

I've been trying to update my backup script such that it saves data on a remote server instead of on a local disk. I have succeeded in converting the entire script but the last part in which I remove ...
1
vote
1answer
38 views

copy files with md5-based target name using find and xargs

I have a directory tree with many .dat files, where many of them contain special characters. They are used by another process which is only able to process files containing ascii characters. My idea ...
1
vote
3answers
122 views

Using a function defined in a parent script

I wrote the following script in the test.sh: #!/bin/sh compare() { if [ $1 != root ]; then echo "Fail" >> CAT1.txt fi } awk -F: '$4 == 0' /etc/passwd | cut -d: f1 | xargs -n1 -i bash -c ...
1
vote
2answers
91 views

find: multiple `-exec`s with conditions

I am trying to include the standard C package stdint.h to files which have the word LARGE_INTEGER, as a part of conversion from Windows to Linux drivers as discussed here for datatypes. I know the ...
9
votes
5answers
459 views

find | xargs shasum creates checksum of checksum file itself (prematurely) and fails when checking

My problem (in a script with #!/bin/sh) is as follows: I try to checksum all files in a directory for archival purposes. The checksum (in my case sha1) file with all filenames should reside in the ...
2
votes
1answer
508 views

Piping multiple lines within bash script

I have some complicated logs that I try to parse. What I want is to find a string H, get column 5 from the line that matches, and then take all other lines where column 5 matches the line with the ...
1
vote
3answers
184 views

How do I get the current line count from xargs?

I want to grab every 5 images in a directory and merge them together into a new file with a unique filename per 5 image group. find *.jpg | xargs -n 5 -i convert {} -append {#}.png This is really ...
0
votes
1answer
188 views

Using curl with xargs connection hanging sometimes - any way to retry?

echo $LIST | xargs -I{} -n 1 -P 8 sh -c 'curl -o backup.dump http://url.com' I am running this for a large amount of files (around 300). After a while, sometimes curl hangs and won't progress for a ...
3
votes
4answers
182 views

Provide strings stored in a file as a list of arguments to a command?

I install a list of URLs in a text file named myurls: http://www.examples.com/1 http://www.examples.com/2 http://www.examples.com/3 How shall I pass these URLs to wkhtmltopdf as inputs? The direct ...
2
votes
1answer
69 views

Unset all ENV variables matching _PROXY

I'm trying to unset all environment variables that match _PROXY: env | grep -i _proxy | column -t -s '=' | awk '{ print $1 }' | grep -iv 'no_proxy' | xargs -0 -I variable unset variable but it's ...
1
vote
1answer
501 views

piping commands after a piped xargs

HP-UX ***** B.11.23 U ia64 **** unlimited-user license find . -type d -name *log*|xargs ls -la gives me the directory name(the ones which contain log in the directory name) followed by all files ...
6
votes
5answers
3k views

Deleting files with spaces in their names

I am trying to delete all the files with a space in their names. I am using following command. But it is giving me an error Command : ls | egrep '. ' | xargs rm Here if I am using only ls | egrep '. ...
7
votes
2answers
658 views

Why does xargs skip first argument when passing to subshell?

Looking for a way to invoke more than one command in a xargs one-liner, I found the recommendation in findutils to invoke the shell from xargs like this: $ find ... | xargs sh -c 'command $@' The ...
2
votes
2answers
151 views

Copy files with parent folder to a new directory

I want to copy some files and include their parent directory in the process. The current structure is similar to: /Module1/A/downloads/m13312/file.pdf /Module1/A/downloads/m17312/file.pdf ...
2
votes
1answer
55 views

xargs not prompting after each line

I want to know the size of all the data files in my directory. I tried using the following command. The file names all start with data_. find . -name 'data_*' -type f | xargs ls -sh -n1 -p I do ...