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

learn more… | top users | synonyms

1
vote
1answer
20 views

Ubuntu shell curly brace expansion - confusion with sox command

I'd like to search through multiple subdirectories and convert all .mp3 files to .al files. Here's how I do it: find . -name '*.mp3' -type f -print0 | xargs -0 -t -r -I {} sox {} -r 8000 -c1 -e a-law ...
0
votes
1answer
35 views

How to Execute !gvim current line in Viewer?

Code find-xargs(less)-gvim %http://unix.stackexchange.com/a/277889/16920 find . -name "*.tex" -exec grep -il "agent" {} + | less -s -M +Gg Output ./InfectiousDiseases/1.4.2016.tex ...
1
vote
0answers
17 views

Use a bash array as a place-in argument list (with Midnight Commander)

I'm having a little bit of trouble figuring out how I can use a bash array for an argument list. so far, the below code does not work. The %s below is Midnight Commander specific. F=(%s); for i in ...
0
votes
1answer
52 views

What is the meaning of xargs show limits output

You can use xargs to discover limits about the commandline you're using: $ xargs --show-limits Your environment variables take up 1901 bytes POSIX upper limit on argument length (this system): ...
1
vote
2answers
37 views

Is there a means of manipulating the order of arguments of stdin when using xargs, much like how awk as $0,$1,$2,etc..?

I'm trying to learn how to manipulate pipe flow using xargs. Often times I need the output of my commands to be fed into commands that can't be piped into by stdout. awk seems to have some ...
2
votes
1answer
28 views

Passing multiple arguments in middle of command with xargs

Is there a way to pass multiple arguments in the middle of a command using xargs? For example, I have a file javaoptions.txt which contains a default set of Java options. I would like to be able to ...
2
votes
2answers
245 views

xargs and < and > to the same files

I want to run git stripspace on all my source code files, on each build (or precommit or just manually), to remove extraneous whitespace, and later maybe to format the code in a standard way, So ...
3
votes
2answers
38 views

pipe process output to command split by line and whitespace

On the system I'm using I often need to cancel jobs I run. I can check my jobs like this: $ showq|grep jquick 2001744 jquick Running 120 00:08:26 Mon Apr 11 11:06:02 2002020 ...
2
votes
1answer
77 views

GNU parallel excessively slow

I need to run grep on a couple of million files. Therefore I tried to speed it up, following the two approaches mentioned here: xargs -P -n and GNU parallel. I tried this on a subset of my files (9026 ...
1
vote
1answer
34 views

Interactive remove files listed with paths in text file

I am trying to interactively remove files listed with their paths in a text file. The command I am trying is: xargs rm -i <filelist.txt The error I get is: rm cannot remove ...
2
votes
1answer
66 views

Different output of `find | xargs ls` for the same command on different Ubuntu versions

I have two Ubuntu installations: A: 14.04.3 LTS (GNU/Linux 3.13.0-77-generic x86_64) B: 14.04.2 LTS (GNU/Linux 3.13.0-61-generic x86_64) I'm running the following command: find . -name ...
1
vote
2answers
59 views

how to move all files from a pipe into a directory ?

I performed a file-command on all elements in my Desktop directory: ~/Desktop > file * then I grepped all the lines who have the string "image" in the description: ~/Desktop > file * | grep ...
3
votes
2answers
64 views

Passing a list of two PIDs to xargs only kills the first using ssh

I'm retrieving a list of two PIDs that I want to kill. My pipeline looks something like ps -ef | grep foo | grep -v grep | awk {'print $2'} | xargs kill -9 Both processes are killed when executing ...
4
votes
3answers
1k views

Append line to many files

I want to add some text to over 200,000 files I am trying this find . -name *.txt -print | xargs -I % echo "hello world" >> % But nothing is happening. When i run find . -name *.txt it work ...
1
vote
1answer
11 views

How to repeat variables twice in xargs

How can I make the second echo to echo out test in this example as well: echo test | xargs -I {} echo {} && echo {}
3
votes
2answers
160 views

How do I decode a list of base64-encoded file names?

I have a list of base64-encoded file names in the pattern of {base64-encoded part here}_2015-11-12.pdf. I'm trying to decode that list of files and return it on the command line as another list, ...
0
votes
4answers
98 views

Search for and remove files safely

I would like to search for all the nohup.out in my mounted filesystems, and delete them. There are some directories and files whose filenames contain space, so I think of xargs -0. To be safe, I ...
0
votes
2answers
59 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 ...
2
votes
1answer
46 views

Why is the xargs -i option deprecated?

I was reading the Linux man page for xargs recently, and it appears that the -i option is deprecated. To quote from the documentation: -i[replace-str], --replace[=replace-str] This ...
0
votes
1answer
35 views

Using xargs to construct a find command that excludes a list of directories from an environment variable

I know how to exclude certain directories from find: find <path> ! -path <path to exclude>. But this can be too tedious to type out when I need to exclude a lot of directories or simply ...
0
votes
1answer
41 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 ...
1
vote
2answers
114 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 ...
3
votes
3answers
131 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
34 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 ...
-1
votes
2answers
70 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
35 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 ...
8
votes
4answers
4k views

How to delete commands in history matching a given string?

I need to delete all commands in my history matching a string. I've tried: $ history | grep searchstring | cut -d" " -f2 | history -d -bash: history: -d: option requires an argument $ history | grep ...
1
vote
2answers
91 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 ...
21
votes
3answers
2k views

gnu find and masking the {} for some shells - which?

The man page for gnu find states: -exec command ; [...] The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, ...
1
vote
2answers
50 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 ...
9
votes
2answers
5k views

“Argument list too long”: How do I deal with it, without changing my command?

When I run a command like ls */*/*/*/*.jpg, I get the error -bash: /bin/ls: Argument list too long I know why this happens: it is because there is a kernel limit on the amount of space for ...
1
vote
2answers
75 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
27 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) ...
0
votes
0answers
72 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 ...
7
votes
5answers
679 views

Have xargs use alias instead of binary

Bash 4.2 on CentOS 6.5: In my ~/.bash_profile I have a bunch of aliases, including: alias grep='grep -n --color=always' so that I can get color highlighting and print line numbers automatically ...
2
votes
1answer
217 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 ...
2
votes
3answers
202 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 ...
0
votes
1answer
48 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
134 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
94 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 ...
1
vote
1answer
120 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 ...
1
vote
0answers
56 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
87 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
1answer
853 views

How to remove all but last 10 files [duplicate]

I accumulate sequentially named files as the result of an automated process, and I would like to keep only the last 10 around. I tried this, which had the effect of deleting everything: ls -r | more ...
2
votes
5answers
200 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 ...
2
votes
2answers
53 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 ...
1
vote
1answer
52 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
53 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
26 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
48 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 ...