Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [xargs]

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

1
vote
2answers
14 views

Use tmux attach with xargs

I'd like to create an alias that lets me browse all of my tmux windows with FZF and then attach that single window. What I have so far: tmux list-windows -t main -F '#{session_name}:#{window_name}' | ...
0
votes
1answer
35 views

Find and rename first result in linux?

I have try using this commanline. find *.txt | head -1 | xargs -0 mv *.txt test.txt i receive. mv: target ‘02.txt\n’ is not a directory What wrong :(?
0
votes
2answers
284 views

How to get line number in xargs?

I want to upload some files to machines in parallel. There's a list of hosts and a list of files that should be uploaded by index: 1.txt goes to hostOne, 2.txt goes to hostTwo etc. Here's what I try ...
0
votes
1answer
664 views

using xargs pass arguments to sub shell with pipe

I want to rename a number of files. I think I can use xargs to do it. find ./ -name "upload.log-*" ./upload.log-20180622.gz-20180624.gz-20180626.gz ./upload.log-20180624.gz-20180626.gz ./upload.log-...
0
votes
1answer
494 views

Pass command output as argument in grep

I want to compare two text files for changes line by line. If the files are store locally I know I can do it with grep -Fxvf file1 file2 I have a problem because file 2 is in Hadoop File System. I ...
0
votes
1answer
105 views

Replacing a line in multiple files

I have a list of files and corresponding line numbers where I want to perform the substitution: s/LOG.error/LOG.warn There are other places where this might occur and don't want to disturb those ...
1
vote
1answer
43 views

How to move the folders to new directory based on their match in csv file?

In my present directory I have many folders like F1, F2, F3, F4, F5, F6, F7, F8, F9, F10. I have a csv file "dan.csv" in the present directory which has a column with folder names. csv file looks ...
3
votes
3answers
182 views

How to pipe a single item from a command output into another command?

Basic example using grep (note that grep would not be my only use-case for this): $ grep -Irl "foo" path/to/directory/help.js path/to/directory/config.js path/to/directory/task.js Now I want to open ...
2
votes
1answer
619 views

Specify a list of files as input into pdftk

I have a list of files that I need to specify as input to pdftk so it will concatenate them in the order specified. I don't see an input file list as an option in the pdftk man page, but perhaps ...
0
votes
2answers
404 views

Find get the files I want,the pipe to xargs and Tar don't

I'm using the following command line: find . -mtime -15 -mtime 0 -print0 | xargs -0 tar cjvf /home/user/adjuntos.tar.bz2 The left side of the pipe works like a charm, but the right side of the ...
0
votes
2answers
31 views

find a file and send some text to it

I would like to find a file in folder /opt and send some text to it. I tried the following syntax: sudo find /opt -name filename-*.conf | xargs -I '{}' echo "text_to_send" > '{}' \; Unfortunately,...
1
vote
1answer
146 views

What does this do? `Find … -type d|xargs chmod 770`

What does these two lines do? find /backup/folder -type d|xargs chmod 770 find /backup/folder -type f|xargs chmod 660 I googled around, but can't figure out what d|xargs and f|xargs does.
0
votes
2answers
166 views

Cannot make xargs construct to work

I have a strange problem with xargs. I have an xargs construct which does not work, even though when I echo the command, it works perfectly. My one liner is the following: exiftool -p ...
0
votes
1answer
112 views

ssh into a machine and search for process, kill using xargs

I am doing this, guastest@iridium06.psc ~> ssh <machine> jps | gawk '$2 == "<process>" {print $1}' | xargs kill kill: sending signal to 75797 failed: No such process guastest@iridium06....
4
votes
2answers
303 views

Add text to list of files

I'm trying to use xargs to manipulate a set of files. A file called filelist.txt contain the file names john paul george ringo steve I can create all these files with this command: cat filelist....
2
votes
1answer
1k views

xargs on windows: No such file or directory

I wanted to resync the tags on my local git repository with the ones on our remote server, using this answer provided on StackOverflow: git tag -l | xargs git tag -d git fetch --tags I've got git ...
0
votes
2answers
290 views

oldest to newest file in directory tree and delete each file interactively

In the step 1, I am trying 'find' the oldest file in directory tree, which I solved by following this question. Now I want to use xargs to delete interactively from oldest to newest. Since this ...
3
votes
2answers
1k views

Multiple read from a txt file in bash (parallel processing )

Here is a simple bash script for HTTP status code while read url do urlstatus=$(curl -o /dev/null --silent --head --write-out '%{http_code}' "${url}" --max-time 5 ) echo "$url $...
1
vote
2answers
745 views

Piped xargs doesn't execute the command

I want to monitor nginx access.log for malformed requests and notify myself about such cases. To do this i have written following command: tail -n0 -f access.log | grep --line-buffered '\{' | ...
0
votes
1answer
565 views

Use xargs on file or content that contains quotes/single quotes

I am having difficulty using xargs with files with ', is there a way to by pass this problem? $ find . | xargs -I FILE echo FILE xargs: unterminated quote file name $ ls mike's ...
1
vote
1answer
506 views

How to generate a list of URLs in bash?

How can I generate a list of URLs in bash so that I can pipe them to xargs and then to curl? http://somewebsite.com/{}.file where {} is a number.
1
vote
1answer
1k views

How to launch multiple urls per process with cURL?

I am trying to download a list of URLs with cURL with multiple URLs per process. The following works but it returns a weird result if the xargs -L parameter is more than 1. I want to launch 8 ...
1
vote
0answers
34 views

Summing selective du sizes output

I am trying to find out how much space is consumed in total by files exceeding 50M in size. I am able to generate a list of file sizes with the following command: find $PWD/soccer -maxdepth 50 -type ...
1
vote
1answer
86 views

How to rename multiple file name include subfolders?

For example i have the following files: ./dirA/fileA.png ./dirA/fileB.png ./dirA/fileC.png ./dirB/fileD.png ./dirB/fileE.png ./dirB/dirC/fileF.png Is there any one line command or script to rename ...
1
vote
1answer
70 views

How to pass console input to xargs

I am trying to pass a file name as an argument to wc -l through xargs. Below is the command I tried: cat > xargs wc -l I am getting below error cat: invalid option -- 'l' Try 'cat --help' for ...
3
votes
3answers
3k views

Xargs pass input to command that contains a pipe

As a vehicle to understand how to manipulate binding precedence with pipes, I'm trying to print the path of one file per directory - for every directory: find $PWD -type d | xargs --delimiter "\n" -I%...
1
vote
1answer
314 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.a ...
1
vote
1answer
451 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 '...
-2
votes
2answers
879 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: Fatima ...
2
votes
3answers
505 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....
1
vote
1answer
305 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 /...
3
votes
1answer
313 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
438 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....
0
votes
1answer
656 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 ...
0
votes
1answer
201 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 ...
3
votes
2answers
735 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 ...
1
vote
2answers
59 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?
2
votes
2answers
404 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 ...
1
vote
0answers
204 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
133 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
2answers
123 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
1k 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
1answer
318 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 {} ...
2
votes
1answer
2k 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
45 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).../...
0
votes
1answer
127 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
3answers
1k 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 ...
1
vote
2answers
177 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/...
0
votes
1answer
666 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 ...
4
votes
3answers
1k 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 ...