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

learn more… | top users | synonyms

0
votes
1answer
13 views

How to list SVN repository name with latest revision number

I want to get for each of my SVN repository its latest revision number. My command looks like currently like this: ls | xargs -n 1 svnlook youngest This prints a list of revision numbers. But I'd ...
2
votes
2answers
29 views

finding a folder names based on list contained in .txt file

I have a .txt file containing 150 different ID number on each line like so: 12345 15876 19643 12586 Located in the same directory as the .txt file, I have 300 folders and I want to copy only the ...
0
votes
1answer
43 views

xargs give me error cannot open `{}' (No such file or directory)

Can anyone explain why the command below produces the following error: cannot open `{}' (No such file or directory) Command $ ls -al|grep -v '^d\|^$'|awk '{print $10}'|xargs file '{}' I get the ...
1
vote
1answer
38 views

What does '-t' do in mv command? Example below

ls -lrt |grep 'Jun 30th' | awk '{print $9}' | xargs mv -t /destinationFolder I'm trying to move files from certain date or pattern or createuser. It doesn't work properly without the -t option. ...
2
votes
3answers
65 views

Accessing each line in .txt file, download and rename links

Let's say I have a .txt file where I have a list of image links that I want to download. example: image.jpg image2.jpg image3.jpg I use: cat images.txt | xargs wget and it works just fine What I ...
0
votes
3answers
56 views

piped command after grep not working

I want to monitor a file. So I have tailed a file using below command, to execute a script per line. tail -3f logfile.log | grep "action.*add" | sed -u -e "s/^/'/" -e "s/$/'/" | xargs -L 1 -P 5 bash ...
2
votes
2answers
69 views

Pass input file through pipe as argument?

I have two issues. I am trying to pass files through a pipe as an argument, and I am trying to use that file as a variable inside the sh function. Here is my command: find . -name 'segment*' | ...
1
vote
3answers
92 views

How to Distribute Computing of `tar czf` for Longer Time?

My systems go under heavy load when I run sudo tar czf /media/masi/ntfsDisc/backup_home.tar.gz $HOME/ Fans goes to max etc. I would like to find a better balance between computing and power ...
1
vote
2answers
57 views

parallel processing using xargs

How to execute a bash script in parallel for each line ? Actually, I will be tailing to log file and for each line found, I want to execute script in background something like below: tailf logfile....
-1
votes
1answer
53 views

How can I pass the file names to xargs and truncate them? [closed]

I have to write a script which will ssh into servers and truncate log files My script is #!/bin/bash for server in $(cat c10_servers.txt) do ssh $server " ls /var/log/hello grep -i hello.log. |...
1
vote
1answer
64 views

xargs: argument line too long

When I run below line in a shell script: /sbin/iptables-save -t filter | grep -- "-A INPUT" | grep -v "fail2ban-\|f2b-" | sed -e "s#^-A#apply_rule /sbin/iptables -D#g" | xargs -0 echo -e "`...
0
votes
2answers
40 views

How to print lines using find and sed in multiple files?

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files. I've tried this : find . -path "*alder/ * / * .html" -print | xargs sed -...
3
votes
1answer
47 views

Shell syntax for redirecting arguments?

If I want to redirect not the stdio but as arguments the output of a program , should I use xargs? For example, I do ls and I want the filenames to be arguments to the next command rather than an ...
2
votes
2answers
60 views

xargs on OSX: illegal option --

I'm on OSX. I want to run a python script against all pngs in a particular directory. This is what I've tried: find docs/ -name "*png" | xargs --replace=F python myscript.py "F" But I see this: ...
3
votes
3answers
69 views

How can you move or copy specific files from a list of text files

So I have a directory of like 200 of the the following types of files: gre_6_c1_d34567.h3 gre_6_c1_d95543.h3 gre_6_c1_d42354.h3 gre_6_c1_d01452.h3 gre_6_c1_d23168.h3 gre_6_c1_435435.h3 The only ...
3
votes
4answers
101 views

'find -mtime -1 -print | xargs tar' archives all files from directory ignoring the -mtime -1 argument

I'm trying to create a backup script. I've managed to get this script working fine on a CentOS 6.7 machine and am now trying to get it working properly on Debian 7. I am running into a problem I can'...
0
votes
3answers
80 views

Right syntax for awk usage in combination with other command inside xargs sh –c

How to make this command work: ls * | xargs -I {} sh -c 'echo {}; awk '{print $1}' {} | uniq' It should do the simple thing: print for each file in the folder its name and uniq values in the first ...
0
votes
1answer
43 views

xargs -I option

The xargs manual says : -I replace-str --replace[=replace-str] -i[replace-str] Replace occurrences of replace-str in the initial arguments with names read from standard input. I don't ...
1
vote
3answers
111 views

How can I recursively replace a string in file and directory names?

I have a git clone of etckeeper, and I'm trying to rename all files and directories with etckeeper in the name to usrkeeper. For example, ./foo-etckeeper-bar should be renamed to ./foo-usrkeeper-bar. ...
1
vote
1answer
33 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 ...
1
vote
0answers
25 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
85 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
40 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 ...
0
votes
1answer
47 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 ./...
2
votes
1answer
49 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 ...
3
votes
2answers
47 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 ...
1
vote
1answer
38 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 'directory1/...
3
votes
1answer
134 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 ...
2
votes
1answer
93 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 "nosuch....
1
vote
2answers
78 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
99 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
2answers
238 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, ...
1
vote
1answer
25 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 {}
0
votes
4answers
113 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 ...
2
votes
1answer
50 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
37 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
60 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 ...
4
votes
3answers
192 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
52 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
vote
2answers
65 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
90 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
38 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
112 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
58 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 file,...
0
votes
0answers
28 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) APPLICATION_CLIENT_HOME=../...
1
vote
2answers
114 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
93 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
536 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
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
154 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 /...