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
89 views

Getting xargs: unterminated quote when trying to find text in files

I'm using Mac 10.9.5 with bash shell. I'm trying to search for instances of text within a group of files, but for some reason, in one particular directory, I get this bizarre "Unterminated quote" ...
0
votes
2answers
33 views

Move most recently modified file

I am trying to move the most recently modified file in "Pictures/". This is what I've tried: find Pictures/ -maxdepth 1 -type f -mmin -60 -print0|tail -1| xargs -0 -I {} mv "{}" Dropbox/somefolder/ ...
0
votes
1answer
52 views

`if` statement with stdout && passing xargs through pipe

Say I have a list.txt of files I want to check. cat list.txt and for each file, I want to perform an action cat list.txt | xargs -I {} touch {} But depending on the outcome of the action, I want ...
0
votes
1answer
36 views

How to copy a list files to a list of directories or subdirectories

I'm trying to figure out how to copy a list of files to a list of subdirectories. eg. I have 300 files to copy into 300 subdirectories - 1 to 1. file1 -> dir1/sub file2 -> dir2/sub file3 ...
0
votes
2answers
82 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 ...
2
votes
1answer
43 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 ...
0
votes
2answers
95 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
148 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
207 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
41 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
36 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
39 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
102 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
657 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
90 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
340 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
93 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
2answers
68 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 ...
3
votes
1answer
710 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
75 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
82 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
321 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
201 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/ $ ...
4
votes
1answer
5k 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
379 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
300 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
247 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
166 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
3k 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
332 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
601 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
238 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
86 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
183 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
64 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
1k 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
832 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
952 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
75 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
323 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
323 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
894 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
485 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 ...
6
votes
5answers
5k 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
597 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
477 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
847 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
597 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
149 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
554 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*' ...