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
1answer
29 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 ...
0
votes
2answers
58 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
76 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
36 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
1answer
21 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
30 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
2answers
58 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
119 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
56 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
219 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
66 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 ...
1
vote
1answer
45 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
247 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 ...
4
votes
1answer
63 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 ...
0
votes
3answers
376 views

Copy top level folder structure without copying files in linux

I would like to copy a folder structure (without the files), but only the top level folders. That is, with my source: folder a * folder 1 * folder 2 * folder X folder b * folder 3 folder c I ...
2
votes
2answers
77 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
144 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
147 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
196 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
184 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
185 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
129 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
1k 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 ...
4
votes
3answers
261 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 ...
3
votes
2answers
287 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 ...
2
votes
3answers
172 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 ...
0
votes
3answers
76 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 ...
1
vote
3answers
152 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
59 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
666 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 ...
0
votes
2answers
498 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
710 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 ...
1
vote
2answers
68 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.
2
votes
3answers
246 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 ...
0
votes
1answer
256 views

Use java and xargs(?) to supply only arguments to java program and not replace stdin

I have a written a small java program that takes arguments from the commandline and should then be interactive. When I want to test with large input I want to pipe the contents of a file to the JVM ...
2
votes
3answers
616 views

sudo to kill output of ps, awk, xargs

I want to kill root owned processes containing foo in the process name sudo sh -c "ps aux | grep [f]oo | awk '{print $2}' | xargs kill -15" this command fail as awk and xargs are ignored. sudo sh ...
0
votes
3answers
361 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 ...
3
votes
5answers
2k 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
1
vote
3answers
328 views

what is diff bentween xargs with braces and without in linux

I want to know what is the difference between this ls | xargs rm ls | xargs -i{} rm {} Both are working for me
0
votes
2answers
395 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 ...
3
votes
2answers
596 views

How to use wildcards in a xargs-command?

I've got a directory with numbered files, e.g. 1_foo.txt 2_bar.asc 13_test.png, and want to move them into individual directories (e.g. 1, 2 and 13) using as simple a bash command as possible. ...
1
vote
3answers
441 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?
0
votes
4answers
144 views

how to do grep in the man command of linux using xargs?

I want to grep into a manual of a particular command say man grep |grep 'insensitive'. One of friends told me that It can be done using xargs but I cant seem figure out how. I want to do it using ...
1
vote
3answers
403 views

Difference between xargs /bin/ls and exec ls?

Hi this may be a very newbie question, but why doesnt the xargs /bin/ls work in this case? I thought it was supposed to be faster? Also what are those /fd/3 directories? sh-3.2# find / -name 'GOALS*' ...
0
votes
2answers
179 views

find -print0 | xargs -0 grep not working as expected on Ubuntu 10.04

I've got a bit of a weird issue. If I run: find . -iname '*.php' -o -iname '*.pl' -o -iname '*.html' | xargs grep -i users I get a load of errors for filenames containing spaces, but also some ...
0
votes
2answers
440 views

xargs and cp: find-style “{}+” multiple expansion?

I'd like to copy a group of files to destination folder. But without needing to spawn a new instance of cp for each operation. The arg format for cp seems to be: cp src_file1 src_file2 src_file3 ...
3
votes
1answer
737 views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
0
votes
3answers
202 views

Passing multiple sets of arguments to a command

instances contains several whitespace separated strings, as does snapshots. I want to run the command below, with each instance-snapshot pair. ec2-attach-volume --instance $instances --device ...
2
votes
3answers
243 views

Xargs string interpolation, not by inserting a space

I want to repeat touch ../template/filename where filename comes from find. I want xargs to apply the touch operation, but I dont want it to insert a space like it usually does which derives into: ...