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
0answers
8 views

Is there a limit on xargs of GOW on windows?

I use GOW tool kit on windows which contains many linux tools I found that if the current directory contains several directories and many files (much greater than 1000), If I run gfind . | xargs rm ...
1
vote
1answer
24 views

bash xargs: same command gives different output

When I run ls -1 *.a | xargs -I{} echo {} | sed 's/.a//' The output is 1 2 3 When I run ls -1 *.a | xargs -I{} bash -c "echo {} $(echo {} | sed 's/.a//')" and the output is 1.a 1.a 2.a 2.a 3....
10
votes
4answers
18k 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
1answer
39 views

xargs with two command - mkdir and sed

I want to create catalogs and in the same line I want to change path and save it in the output file I don't want to repeat code, so I tried: cut -d ';' -f 1 tmp1 | tr '.' '/' | xargs -I % bash -c '...
-1
votes
1answer
69 views

Search for string inside pdf with pdfgrep and outputs only file name

I'm using pdfgrep to search for a name inside a pdf: pdfgrep -H 'Fatima Alves' RE/* This commands will output the file name and the name: RE/2011-01-RE_60822079000168_23022016_153923(1).PDF: ...
2
votes
3answers
80 views

How to use xargs and sed to pipe results to an array?

I'm pulling JSON from a REST endpoint using curl and then parsing it using the node package json to get at some of the JSON attributes, which I use later in some app configurations. curl -s http://52....
12
votes
2answers
6k views

Create symlinks recursively for a whole tree

I am seeking for a command that would re-create a whole tree of files in a different directory. I would prefer to have all symlinks absolute. Can I do that with a find and xargs? ;-)
2
votes
3answers
5k 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
44 views

xargs; How & When?

What exactly is xargs? How do you use it? When would it be considered pragmatic, or otherwise appropriate to do so?
1
vote
2answers
44 views

Pass all *.txt files to a Python script in parallel

I have a Python script that takes a .txt file and does something with it. I need a Linux shell command that will search for .txt files throughout the system and pass the .txt files to my Python script....
1
vote
1answer
49 views

xargs misinterprets backslashes on windows

I am using gnuwin32 utilities on windows 7. I want to pipe a file list to xargs to remove the files. but if i pipe normal windows paths in then xargs interprets and removes the backslashes dir /B /...
2
votes
1answer
39 views

why doesn't `find . -name '*.jar' | xargs jar tf` work?

I ran this find . -name '*.jar' | xargs jar tf hoping it would, find all the .jar files and execute jar tf on them (to view the content). But it didn't seem to work!!!
1
vote
2answers
44 views

Retrying failed command that is run with xargs

I have a script that rsync's files over in parallel using xargs and rsync daemon mode. I occasionally get errors with rsync due to writes happening on the source. I want to be able to retry the rsync ...
0
votes
1answer
61 views

Delete files if condition is met

I have the following directory tree: /Directories/ /Directories/somedir/somefile.mkv /Directories/somefile.rar I'm trying to find a way to delete the .rar file if the .mkv file exists and is larger ...
3
votes
2answers
75 views

execute a command for each line of stdin immediately?

How do I execute a command for each line of stdin immediately? Example: (echo abc; sleep 10; echo def;) | ??? The xargs tool does not do the job because it blocks until it sees all the data (waits ...
0
votes
1answer
44 views

What does xargs do exactly in this case?

I recently came across the following two examples Example 1: List only directories ls -l | grep "^d" Example 2: Search inside files ls | xargs grep -i "Find Some String" Now i have read from ...
6
votes
3answers
3k 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. ...
1
vote
2answers
324 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
0answers
36 views

How can I get xargs -I to work with large strings

Here's a contrived usage of xargs that I'm running on Mac OS X: $ head -c 128 /dev/urandom | openssl base64 -A | xargs -I {} echo {} rPeQFDtZ+icGeminAWK70Qmo/AQO5ZiZsusZuP/hZeFP2lId5efwhpy/...
0
votes
2answers
65 views

remove pattern with random numbers (digits) from php files

I am trying to remove or replace the digits ((random numbers)) in big numbers of php files using find & xargs and grep with sed etc .. the numbers looks like that inside the php file /web/...
1
vote
1answer
30 views

remove wayback toolbar code in bewteen lines

I am trying to remove Wayback toolbar code using some tools such as find & xargs and grep with sed etc issue that the size of the html & php files it's over 7GB & as well as the pages ...
0
votes
1answer
184 views

how to move files that contain string using find, xargs, grep, in linux

i have many php files maybe over Three million.. how can i use grep with xargs and find with mv to find contain the string in files and move them to directory if they match. I try like that find . -...
1
vote
0answers
57 views

fswatch does not pass arguments to xargs

I'm starting using fswatch on os x. I've read tutorial, but example from there does not work for some reason. I'm executing fswatch /$HOME/Projects/utils/configs/.vimrc | xargs -0 -n 1 -I {} echo {} ...
6
votes
3answers
3k views

Replacement for xargs -d in osx

In Linux, you can use xargs -d, to quickly run the hostname command against four different servers with sequential names as follows: echo -n 1,2,3,4 |xargs -d, -I{} ssh root@www{}.example.com ...
2
votes
1answer
223 views

Delete all not jpeg files

I have exercise, in which I have to delete all files, which are not jpeg. I tried find -type f |xargs file| grep -iv 'jpeg', but it doesn't work.
2
votes
2answers
28 views

How can I find a particular named file within a particular named directory that could be anywhere in file system?

I am trying to find a file within a directory where both the name of the file and the name of the directory are known. For example, say I want to find "...don't know this part of file path stem).../...
2
votes
3answers
366 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 ...
0
votes
2answers
118 views

find/xargs, filenames with spaces, and quotes

I'm looking for a way to get find and xargs (GNUWin32, under Win7, both programs at version 4.1) to play along, with filenames that contain spaces. Getting the filenames into xargs as one was one ...
1
vote
3answers
192 views

add new line after every end of file's contents while merging multiple files

I have written shell script to merge different file's contents I have created directories f1,f2,d1,d2 and files under them , I need to merge all files's contents : comand is (find /home/ah5024331/f1 ...
0
votes
1answer
62 views

How to store data from different netcat connections in separate files?

I need a server that should receive data streams, store them in files and send further. Each connection should create a file with corresponding timestamp in file name, then write to it. My solution: ...
1
vote
2answers
46 views

Can xargs evaluate $HOME?

When I type in echo $HOME/Downloads | xargs cd It correctly changes directory to $HOME/Downloads. Maybe that is because echo evaluates $HOME before piping to xargs. However if I type echo '$HOME/...
1
vote
2answers
480 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 | ...
0
votes
1answer
172 views

How would one pipe from socat to sed to bc to xargs?

I have a server outputting some numbers, I'm reading them with socat, then using sed, I turn those numbers into some math equations, I run them with bc, then I need to pipe them into xargs. socat -u ...
3
votes
2answers
189 views

Xargs: change working directory to file path before executing?

I have a large folder of RAR archives. There is a significant hierarchy of folder levels. I want to unRAR the entire collection of archives all at once. I have the following one-liner, which will ...
1
vote
1answer
3k views

Executing lines of a file with xargs, using stdout redirection

I have a file that has lines that look like this: "http://api.domain.com/path/to/resource?format=json" > output.xml and I execute the following from my command line: cat file | xargs -L 1 -I {} ...
1
vote
3answers
800 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
1answer
111 views

Is there any difference between -exec cmd {} and xargs -I?

Normally, xargs bundles everything together, but when used with the -I flag it seems to put evaluate everything as a single line. Does this mean it loses its speed advantage? Also if the -exec cmd {} +...
1
vote
0answers
210 views

How can I use xargs replace but keep space delimiter?

Consider the following xargs usage: echo Alice Bob Carol | xargs -n1 echo It produces three echo statements like this echo Alice echo Bob echo Carol Consider this modified xargs usage: echo ...
0
votes
2answers
299 views

Chronologically grep or zgrep files in folder depending on file extension (xargs)

I have dozens of folders which contains both plain text log files and gzipped older logs. My goal is just a one liner to run (one folder at a time) to pull up all grep results based on timestamp ...
1
vote
2answers
173 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
1k 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" ...
1
vote
2answers
350 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
114 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
254 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
541 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
59 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 -...
10
votes
7answers
10k 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
194 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
86 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
11k 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 ...