utility in Unix-like operating systems for passing large numbers of arguments to programs that can only take a small number of arguments

learn more… | top users | synonyms

0
votes
2answers
59 views

xargs + pv = messed up terminal

if i want a little progress indicator on my long-running operation i can use pipeviewer: ssh pc2 cat some.file | pv -nC reading | gzip --fast | pv zipping > some.file.gz this gives me a fun ...
5
votes
3answers
2k views

How to escape file output for compatibilty with 'xargs'?

I have this command: find $1 | xargs touch But files with ' characters in their names fail with "xargs: unmatched single quote", and I guess other special characters would cause the same problem. ...
0
votes
2answers
52 views

Why doesn't xargs on find work with a series of commands using pushd and popd to walk a directory subtree?

On a Linux Centos 4 machine, I am trying to create a simple bash command line to walk a directory structure below an arbitrary current directory and in each subdirectory touch a file, list the ...
2
votes
1answer
32 views

Using xargs with $() - operator precedence?

Inspired by this question. The original question, in short, is "How to turn all :2f into - in all files within a folder". e.g. If I have a file ./abc:2fdef it should be renamed into ./abc-def. At ...
7
votes
4answers
7k views

find: -exec vs xargs (aka Why does “find | xargs basename” break?)

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via basename, but it did't work ...
4
votes
5answers
3k views

How can i move files with xargs in linux

I am trying this and its not working ls file_* |xargs mv {} temp/ Any ideas
3
votes
2answers
2k views

using xargs to cd to a directory

Feeling like an idiot right now. Why does this not work? echo "/some/directory/path" | xargs -n1 cd
0
votes
2answers
70 views

How can I run mogrify over the 3 million JPG files?

I have 3 million JPG files stored in a Linux CentOS 6 server. I want to change quality to %50 file size over 1 megabyte. I wrote this command but got an "argument list too long" error: $ find -type ...
0
votes
1answer
107 views

Find & du to calculate total size vs xargs

Can someone confirm that the following one liner will produce the total human readable size of all the directories which FIND locates as having log in the name? find -type d -name *log* | du -hcs
0
votes
0answers
38 views

I'm trying to list size of folders plus selected files on a portable disk

For the purpose of finding the location of my data among many portable disks, I'm trying to create plaintext lists of the contents of all folders and files of certain extensions and sort them by size. ...
1
vote
3answers
857 views

Run xargs on the first word on a line

Is there a way to run xargs on only the first argument of a line? So if my input is the default output from a grep, like this: ./file1 "matching string" ./file2 "matching 2" What I want ...
1
vote
1answer
27 views

xargs process string as multiple arguments

Linux GNU xargs I have the file doit with arg1 arg2 arg3 arg4 arg1 arg2 arg3 arg4 I want to perform command arg1 arg2 arg3 arg4 command arg2 arg2 arg3 arg4 What I can't figure out is how to ...
1
vote
2answers
32 views

Find two newest change files and compare them

I have a script that wgets a .txt file and datifies the names. I'd like to diff the changes between the newest & next-to-newest file. This is how I am able to select them: ls -t -l | awk ...
1
vote
3answers
407 views

Expanding globs in xargs

I have a directory like this mkdir test cd test touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt I want to run some command such as ls on certain types of files in the directory and have the * ...
1
vote
2answers
66 views

xargs substition of more than one argument

By default xargs will concatenate many lines of its input and pass then to the specified command. For example: echo -e 'line 1\nline 2\nline 3' | xargs echo results in line 1 line 2 line 3 ...
2
votes
2answers
210 views

cat “input file is output file” while trying to combine multiple files into one

The plan was to collect all source lines of Java into one file, recursively: $ find . -name '*.java' | xargs cat >> all.java But there was an error: cat: ./all.java: input file is output ...
1
vote
2answers
69 views

Detect invalid JSON files in directory tree

I want to fail a build if the directory tree contains a JSON file which is invalid according to the jsonlint package from NPM. I thought this would be as easy as running: find . -name \*.json | ...
1
vote
2answers
258 views

batch find/replace using sed or awk

In every file with filename matching pattern1 I want to search for lines which start with pattern2, and add some string in a new line above those matched lines. As a simple example suppose I'm ...
1
vote
2answers
71 views

How do I search for a string in a group of files when some of those files contain spaces?

I'm running Mac 10.7.5. In a terminal, I'll use this command for finding files with strings find src/main -name "*" | xargs grep -i 'mystring' However when the files contain spaces, I'll get ...
0
votes
3answers
398 views

piping output of find to xargs wc gives unreasonable totals

In a project with thousands of files, I wanted to compare total lines-of-code, to lines-of-code just in PHP (discarding CSS, JS, etc). When I run find . -type f | xargs wc -l I the total on the ...
1
vote
6answers
5k views

Pipe output of awk to kill -9

I'm trying to kill any process that has to do with mysql. I'm piecing together a command, and so far, haven't come up with the right solution. One other consideration, is that the last process will ...
1
vote
1answer
47 views

Unhide all .htaccess files on mac

I am trying to unhide all the .htaccess files in my home folder. Below I've pasted what I'm using now, but it isn't working. find ~/ -iname ".htaccess" | xargs chflags nohidden "{}" Anyone knows ...
1
vote
1answer
338 views

xargs -I replace-str option difference

From my understanding, the following should mean exactly the same: ls -1 | xargs file {} ls -1 | xargs -I{} file {} if -I option is not specified, it is default to -I{}. I want to list all files ...
1
vote
3answers
478 views

Create multiple files and name them from command line

I need to create 300 blank files and put them in a folder on my server then name them from a list in a txt file, I have SSH access, so is it possible to do this using command line?
4
votes
1answer
65 views

Trying to understand xargs

The target is not to list temp/run*.* files. The target is to understand why the second command does not work. First command: find . \( -name 'temp' \) -print0 | xargs -0 -L 1 -I datafind ls -ltr ...
2
votes
2answers
78 views

Opening search results with Vim ONLY if they exist

:) In my never-ending effort to get lazier, I am looking for a way to improve my "Open Grep/Ack-results in Vim"-snippet. What I'm currently using to open found files is: vim $(ack -il "pattern") ...
0
votes
1answer
192 views

xargs with shell function doesn't work

I'm using shell function like zip0 () { zip -0rq "$1" "$1"; } And I wanted to use it with xargs like this. $ seq 1 3 | xargs zip0 xargs: zip0: No such file or directory But as the error message ...
1
vote
1answer
163 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
3
votes
1answer
3k views

How can I avoid the “grep: Argument list too long” error?

I'm using Mac 10.7.5 and on a bash shell. I'm trying to find instances of a string in a group of files but keep getting this error Daves-MacBook-Pro:folder davea$ find . -name "*" | xargs grep ...
6
votes
1answer
237 views

xargs --replace/-I for single arguments

I'm trying to use xargs to run a command for each provided argument, but unfortunately the --replace/-I flag doesn't seem to work properly when conjugated with -n. It seems that {} will expand into ...
0
votes
3answers
218 views

Using xargs with find

I want to exclude some directories from searching files and than run the find command to find required files. I am using below command find . -maxdepth 1 -type d | grep -E -i 'sensors' | grep -v ...
4
votes
2answers
196 views

Running find and xargs in background

I want to run this command in background because the process could take a long time. How can I send it to a background process? find /tmp/ -type f -mtime +3 | xargs rm -Rf This does not work: find ...
1
vote
1answer
136 views

Having trouble piping output of dscl -list to -dscl read using xargs

I'm trying to get every user using dscl and reading each of their records using xargs and dscl. I'm not sure what I'm doing wrong, though, because I would expect this command to take each line of ...
1
vote
3answers
2k views

Argument list too long for xargs/exec

I'm working on a CentOS server and I have to move around and cat together millions of files. I've tried many incarnations of something like the below, but all of them fail with an argument list too ...
2
votes
3answers
189 views

Use xargs to send requests to the same server in parallel with netcat

I am trying to devise a one-liner to send text to a simple echo server - but multiple connections in parallel. This is what I'm trying: echo -e A,B,C,D | xargs -d, -i -P 4 echo {} | nc localhost ...
4
votes
3answers
281 views

Spawning multiple parallel wgets and storing results in a bash array to be pretty printed when all wgets are done

I have a long list of urls on my own website listed in a carriage return seperated text file. So for instance: http:/www.mysite.com/url1.html http:/www.mysite.com/url2.html ...
0
votes
2answers
419 views

cURL or xargs: show progress

I am using cURL to download many files and concatenate them to STDOUT. About 100,000 small files. I would like to see progress against the 100,000. Is this possible with curl or by using curl into ...
2
votes
3answers
261 views

Using find, xargs, etc. to output similarly named files

I have a folder full of HTML files: 001.htm 002.htm 003.htm … I want to run Pandoc on them to convert them to similarly named Markdown files: 001.md 002.md 003.md This command works on one of ...
3
votes
2answers
335 views

Why is xargs necessary?

Suppose I want to remove all files in a directory except for one named "notes.txt". I would do this with the pipeline, ls | grep -v "notes.txt" | xargs rm. Why do I need xargs if the output of the ...
0
votes
1answer
129 views

Control mplayer ran by xargs

I feed mplayer with file list from another command: beet ls somequery -p | xargs -d '\n' mplayer When invoked this way, mplayer doesn't react on any standard keys, all I can do is to C-c interrupt ...
0
votes
3answers
79 views

How to call the names of directories after passing them all to xargs?

I'm using find to pass all directories to xargs, and the command on each dir by xargs needs to create a new directory for each, looking like dirname_a, so how can this be done? ie find . -type d ...
0
votes
2answers
260 views

Efficiently stripe incoming one-word lines onto columns?

Consider a stream of one-word lines such as the stdout of $ echo foo bar baz quux xyxxy thud | tr ' ' '\n' foo bar baz quux xyxxy thud I say "one-word" to indicate there is no whitespace other than ...
0
votes
2answers
612 views

xargs -I behaviour

A variable var contains multiple arguments, each split by a new line. echo "$var" | xargs -I % echo ABC % #Results in: #ABC One #ABC Two #ABC Three However, when omitting -I and the % characters, I ...
1
vote
3answers
163 views

Using Xargs with hocr2pdf

I'm trying to use tesseract and hocr2pdf on a series of .tif files in a folder. Using ls *.tif | xargs -I% tesseract % % -l fra hocr produces the html files which have the same file name but with ...
0
votes
1answer
61 views

Why doesn't this xargs + grep combo work properly?

I have two files, team1.txt and team2.txt team1.txt =========== Alex Bob Charlie David team2.txt =========== Alex Charlie Benjamin Zed Noah I want to output the people who are in both team1 ...
1
vote
2answers
847 views

Redirect strace to file

Am trying to trace apache2. These are the commands i'm trying to run. ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace >> trace.txt I tried (ps auxw | grep sbin/apache | awk ...
5
votes
3answers
9k views

Why does this not work? “ls *.txt | xargs cat > all.txt” (all files into single txt document)

Why does this not work? ls *.txt | xargs cat > all.txt (I want to join the contents of all text files into a single 'all.txt' file.) find with -exec should also work, but I would really like to ...
1
vote
3answers
784 views

Why doesn't piping grep output into xargs work with color?

I have a strange issue. My grep has colored output, and if I do something like this: grep -lr '80' /etc/apache2/sites-available/|xargs ls I got: ls: cannot access ...
0
votes
3answers
3k views

Using xargs with mv and mkdir command in Linux

I am attempting to create a directory using the command mkdir. However, I would like to move a subset of files into that directory. I understand I can use xargs, however my attempts have failed. For ...
1
vote
2answers
72 views

Change attributes of all symlink targets in a directory

How to change attributes of all symlink targets inside a directory ? /usr/bin/find /mydir -type l | xargs /bin/readlink | /usr/bin/chattr +s piping three commands wont works. Thanks.