Questions tagged [xargs]

xargs is a command that executes another command and generates its arguments from stdin

Filter by
Sorted by
Tagged with
0
votes
2answers
33 views

Storing array as Environment variable to noninteractive shell with xargs

This is in continuation of Storing array as Environment variable to non-interactive shell - Unix & Linux Stack Exchange. Kusalananda, asked me to ask another question. I want to find all markdown ...
3
votes
3answers
205 views

Opening tab in Firefox using a url on a file

I have a file.txt with some urls and the name of the web. Something like: WEB1: www.url.com WEB2: www.url2.com (No space in the name, and there is a space after the colon) I want to be able to open a ...
0
votes
1answer
20 views

Why xargs -0 adds an extra blank line?

In the example, why xargs -0 adds an extra blank line, and how to avoid it? $ touch a b c $ find . -print0 ../a./c./b $ find . -print0 | sort --zero-terminated | xargs -0 . ./a ./b ./c $ find . -...
1
vote
1answer
36 views

Find files in all directories by name in and copy to another directory using rsync

I have listed file names each per line in list.txt like below filename1.pdf file456.pdf file33.txt ....... I want to search by file name in a directory (including all subfolders in source) ...
1
vote
2answers
74 views

add .sh extension to all bash files

I have a directory containg several files, including those files some are bash scripts but their name doesn't include the .sh extension. I know I need to use the file command to know the type of files ...
2
votes
2answers
31 views

Extract and format timestamp in bash

I have script that returns a list of files with the full path to each file. For e.g. - root/folder/file@1610565763436. Hence, the output looks like /root/folder/file@1610565763436 /root/folder/file@...
0
votes
0answers
13 views

How do I remove all files except some listed in a .csv file [duplicate]

I want to remove all files in a directory while leaving just some specified files, that are listed in .csv file. Let's say I have some audio files in a home/wavs/ folder and a list of .wav files I ...
1
vote
2answers
40 views

How to pipe a number into bc elegantly?

Is there a more elegant way than using xargs -Ix for the following? echo "283" | xargs -Ix bc -l -e "scale=2; l( x )/l(10)"
0
votes
2answers
43 views

Using xargs to copy directories

I'm trying to write a script to copy a set of directories that were created today to another directory. I'm currently using: find /test/downloads/ -mindepth 1 -maxdepth 1 -type d -mtime -1 -printf '%f\...
0
votes
1answer
16 views

A command to get currently installed versions of those listed with “>=” in requirements file (PIP) using grep/xargs

I have a requirements.txt file with versions listed e.g. # requirements.txt channels==2.4.0 colorama>=0.2.3 daphne==2.5.0 django-q>=1.1.4 For versions with == PIP installs that exact version ...
0
votes
2answers
46 views

How to group files from find command into a single line where each file is inside double quotes? [duplicate]

This is a recurrent issue I have always had while dealing with iterations or actions over files found using find. I have the following files: $ find . -name "*ES 03-11*" ./01jan/ES 03-11....
0
votes
0answers
16 views

Why can't I answer to `rm -i`'s interactive prompt? [duplicate]

This is the console output when I try to use find | grep ... | args rm -i to delete a bunch of files, but confirm deletion of each one: user@host:/tmp> touch test1234 user@host:/tmp> find -...
0
votes
0answers
19 views

extracting column value from a command [duplicate]

I've multiple process of xargs running. I want to terminate them all using kill at once . How to do them ? . So far I've tried this ps -a | grep -i xargs | awk '{print $1}' | xargs kill .
5
votes
1answer
160 views

xargs | Use input as command

I would have assumed that following examples work perfectly fine. $ which -a python python3 pip | xargs -I {} {} --version No '{}' such file or folder $ which -a python python3 pip | xargs -I _ _ --...
0
votes
1answer
33 views

xargs sed is renaming files instead of replacing contents

Complex command: git ls-files | grep -E '\.(ts|xml|json|html|js|scss)$' | xargs sed -ie s/##tag##/1.0.0/g And in the past it works and replaces in the correct way. So file version-info.html: <p>...
3
votes
2answers
87 views

How can I stagger process start times when using xargs --max-procs?

I have hundreds of files to be processed but only want 10 processes to be running at a time. Suppose the "doSomething" process takes 20 seconds to complete. The following works but starts 10 ...
0
votes
0answers
12 views

xargs when used with the -x flag overrides the -n flag (number of arguments) on macos catalina 10.15.5

xargs when used with the -x flag overrides the -n flag (number of arguments) on macos catalina 10.15.5. Where can I report this bug? ➜ ~ echo {0..9} | xargs 0 1 2 3 4 5 6 7 8 9 ➜ ~ echo {0.....
0
votes
1answer
31 views

how do I output multiple files with a heading for each one but without needing to page through them? [duplicate]

I am running a file search command with ag -g foo and I'd like to see the contents of the files I find. If I do ag -g foo | xargs more then the more command makes me press the spacebar to advance ...
0
votes
3answers
88 views

Reversing order of pdf files to be processed

Context: Catalina = zsh (preferred) or 16.04 Ubuntu = bash A qpdf example indicates: # To merge (concatenate) all the pages of a list of PDF files and save the result as a new PDF: qpdf --empty --...
1
vote
2answers
57 views

Batch convert images with xargs & convert, how to name output file?

It's known that images can be converted to one single pdf with the following command (assuming images filenames are order correctly): convert *.jpg output.pdf. However, this approach may take too much ...
2
votes
1answer
77 views

xargs replstr not working as expected. {} not accepted as a second argument

The command I'm trying to run: mdb-tables davidoff.mdb | xargs -I {} mdb-export davidoff.mdb {} > {}.csv mdb-export takes two arguments, I'm trying to pipe the second one. And then I want each one ...
0
votes
1answer
39 views

Can't understand how xargs is treating unicode literals

I'm trying to convert unicode literals into readable format. I'm using the -t flag to see what command xargs is going to run before it runs it. I see the following weirdness: $ echo -n "\\\t\\\...
1
vote
2answers
45 views

How to recursively shift `<user_id>`:`<group_id>` by a specific value using `xargs` or `exec`

I'm trying to recursively shift <user_id>:<group_id> by a specific value using xargs or exec. I'm having difficulty with passing output from find to variable with stat function. I'm ...
0
votes
0answers
23 views

Trying to remove directories below a certain size, and they won't delete

I'm using the below command (in a script on a Synology NAS) trying to remove all folders under 100MB, and while the first part of the command can properly display them, adding the xargs rm doesn't ...
-1
votes
2answers
163 views

how to use seq with xargs to curl request [closed]

I'm working on curl commmand that performs an action based upon parms value curl 'http://www.example.com/actionid?id=123' id value i want to pump dynamically so seq 1 10 | xargs -I + curl 'http://...
4
votes
1answer
266 views

Piping a list of values to a bash script

I have a script. myScript. It takes two args. myScript arg1 arg2. Let's say I have three sets of arguments. argA1 argB1 argA2 argB2 argA3 argB3 Is there a way to pipe each line to myScript. I am open ...
0
votes
0answers
19 views

Running whole body request inside a variable break Curl -O command

This command seq 1 300 | xargs -n1 -P3 bash -c 'i=$0; url="http://esjindex.org/search.php?id=${i}"; curl -O $url' i want to adapt for curl request as url variable 'https://abc.ai/hello' -H '...
0
votes
0answers
52 views

Output lost using xargs using curl

Using curl alone as curl 'https://abc.ai/getMultiDashboard/' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0' -H 'Accept: application/json' -H 'Accept-...
0
votes
1answer
14 views

Piping to executable with extra params

I have such a command using pipe curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python on the other side I want to provide extra arguments to get-poetry.py ...
0
votes
3answers
105 views

Command works fine but fails when executed remotely over ssh

The below command works fine of remote AiX server when run on the server. ls -ltr /tmp/*.pid | grep "$(date '+%b %e')" Output: -rwx-rwx-rw-- ........ Oct 1 /tmp/new.pid echo $? 0 I wish ...
2
votes
1answer
44 views

mlocate: how to print files only [duplicate]

I have the following version of locate: $ locate --version mlocate 0.26 Copyright (C) 2007 Red Hat, Inc. All rights reserved. This software is distributed under the GPL v.2. This program is provided ...
1
vote
2answers
62 views

How can I expand a single-quoted tilde from xargs in sh?

I have a list of files stored in a file, and I want to grep each of those files for a search term. However, xargs forwards arguments as single quoted strings, so for all of the files prefixed with a ~,...
1
vote
1answer
41 views

Handle umlauts in file names when using xarg

I've seen some similar questions here where people have problems with xargs handling spaces in file names. Surprisingly, I don't run into this issue, but a similar one. I'm copying a fixed amount of ...
1
vote
1answer
29 views

How can I run `gradlew clean build` in all subdirs starting with given prefix?

I have multiple project directories project-one, project-two, different-project. I want to run ./gradlew clean build within all these directories that begin with project-. Can I use xargs to do that? ...
1
vote
1answer
365 views

Search for a string in all searched files gives /bin/grep: Argument list too long error

I tried the below command to search for in all files user /var sudo find . -type f | xargs sudo grep 202007602 | tee /tmp/202007602.log Output: grep: ./www/html/jenkins/workspace/node_modules/xpath/...
1
vote
0answers
29 views

xargs with zgrep is giving the error

I have many gzipped files and I am trying to find some string pattern from the thousands of file but I am getting extra .gz while trying to zgrep it. Please refer the below, could you please advise. ...
0
votes
1answer
86 views

How to run second command only when first is successful when using find and xargs?

My situation is: I have many files with a name timestep1_i for many values of i and I am trying to combine all the files for timestep1 with a program called combinefiles. I want to do it in parallel (...
5
votes
3answers
441 views

Reliable way to open files given by the result of find … -exec grep … {} \+

I often run commands like this: find … -exec grep … --color=always -l {} \+ and sometimes I need to open the matching files in Vim. But what is the most reliable way to do so? One way seems to be vim ...
0
votes
1answer
39 views

Why does host and nslookup think IP address is a hostname?

Why does this command fail (this is a simplified version of the actual command)? /tmp $ echo 74.6.231.20 | xargs -n1 -I {} echo "$(host -d {})" Trying "74.6.231.20.<REDACTED>.<...
2
votes
2answers
164 views

-exec to xargs conversion in find command

I'm using the below command in my script to perform a dos2unix operation on the files which I copy from Windows to Linux. There are many files, so it takes a considerable amount of time to perform ...
0
votes
0answers
24 views

Issue launching vim using xargs -r on a fzf result [duplicate]

I think I am misunderstanding something in the Linux piping with respect to xargs -r in combination with fzf. In my bashrc I have the function ef () { fzf | xargs -r -I vim } But written like ...
1
vote
2answers
53 views

running tasks in parallel as well writing to single file

#!/bin/bash range=$(seq -f "ma%04g" 5001 5505) for n in $range;do ping -q -c 1 -w 3 -s 10 $n >/dev/null if [ $? -eq 0 ];then awk -F, -v key="${n}" -v ...
5
votes
1answer
228 views

Why is `-r` seemingly ignored when used with `-0` in GNU xargs?

The regular case with linefeeds, xargs calls printf and something is printed: >>printf "foo\n" | xargs -r printf "->%s\n" ->foo >> With an empty input instead, -...
-2
votes
2answers
36 views

How to search for a sub-string in the files which contain another sub-string

I wanted to search for a string in a list of files which has another string. Basically, I had to get the list of files with the first string and then do a search on these files for another string. The ...
8
votes
1answer
764 views

Why do I get an error when deleting entries from Bash history?

I have some commands in my Bash history that I want to remove. I can find them with history | grep "command with password" then remove them with history -d <line-number> However, when ...
0
votes
1answer
26 views

cant modify files with the same name which are in different locations when piping find to xargs

on mac using gnu tools Im not sure whats happening but it seems piping the output of find to xargs has some issue with touching files with the same name that appear in the directory structure in ...
6
votes
5answers
401 views

How to edit a list of generated files whose names contain spaces

I've got a relatively small list of filenames generated from a pipeline based on find. The file names contain spaces and possibly punctuation but definitely no other non-printing characters or ...
0
votes
2answers
86 views

Using tail -f together with sed and xargs

Suppose I have the following process to write a number + single quote to the file /tmp/test every second: for i in {1..1000} ; do echo $i\' ; sleep 1 ; done > /tmp/test I then want to use tail -f ...
2
votes
2answers
32 views

Process in Pipe which Processes 256 bytes at a Time

I have a c program on a Cyclone 5 that does an FFT using the connected FPGA. This program currently takes 256 bytes from stdin and then process it gives the FFT results on stdout. I run it like this ...
1
vote
3answers
398 views

Making a pipe from `ls` to `mv`

I am trying to make a small utility for myself on the command line - for a given current work directory I would like to find the most recently added file and mv it to a name given by argument I have ...

1
2 3 4 5
12