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

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 ...
0
votes
1answer
95 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
99 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
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 ...
4
votes
2answers
248 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 ...
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 ...
8
votes
7answers
5k views

How can I use two parameters at once with xargs?

I need to convert videos but I don't know where are they, so I need to find them. How can I give the result and an output file name to ffmpeg with xargs ? I already find out that I can construct the ...
0
votes
2answers
84 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. ...
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 ...
8
votes
4answers
8k 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 ...
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
4
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
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
212 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
3answers
1k 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
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
3answers
464 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
103 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
669 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
91 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 ...
0
votes
3answers
487 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
6k 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 ...
3
votes
1answer
718 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
602 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
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
322 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
382 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 ...
1
vote
1answer
167 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 ...
2
votes
3answers
240 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
335 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
480 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
324 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
614 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
160 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
87 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
281 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
838 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
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 ...