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
185 questions
0
votes
0
answers
60
views
Are xarg + cp vulnerabler to race conditions?
I'm experimenting with Docker images having 20-70 GiB in a single layer (yes, the software/compiler is so fat). To improve the download and decompression efficiency of Docker, I'm splitting this fat ...
1
vote
1
answer
320
views
Advanced argument escaping with find + xargs and nested commands
I know when you run into problems with piping the output of e.g. find .. to xargs due to 'strange' filenames, it can help to use a specific delimiter (e.g. \0) to actually pass full filenames (e.g. ...
0
votes
1
answer
110
views
How to correctly execute output (with additional arguments) of find?
I'm executing output (with additional argument --version) of find in the following way:
$ find NDK -name clang -executable -type f | xargs -I{} bash -c "exec {} --version"
Android (7714059, ...
0
votes
3
answers
133
views
Why doesn't `bash` work with piped output, when the output is as expected?
I'm running the following command to alias an entire folder of scripts:
ls | grep '\.sh$' | sed 's/\.sh$//' | awk '{print "alias "$1"=\"./"$0".sh\""}' | xargs -...
1
vote
2
answers
327
views
How to run xargs utility on all expanded lines of input?
I have a file with a list of files and directories, containing the wildcard *. I am trying to output the size of the entries with du and would like a grand total.
If I start with:
cat file | xargs du -...
2
votes
1
answer
4k
views
How do you move (mv) in ZSH all files from current directory except two or more to a child directory?
(There is plenty of information about this on bash, but much less on zsh and NOT AT ALL for TWO or more files. No idea how to apply the ^ ("caret") TO MORE THAN ONE FILE).
I want to know (...
0
votes
1
answer
115
views
xargs and echo limited number of replacements
I want to duplicate some text a few times.
Xargs doesn't do more than 5 items.
I don't know if there is a better way to do this.
echo "sometext " | xargs -n 9 -t -I RRRR echo RRRR RRRR RRRR ...
0
votes
1
answer
938
views
Why is xargs unable to call basename properly in a subshell?
I ran into the following problem:
user@machine:/$ echo ./dir/fil | xargs -I {} bash -c "echo $(basename {})"
./dir/fil
Why is it not just printing fil?
So basename seems to get the expected ...
1
vote
1
answer
7k
views
Using jq with xargs
I have a json-file with n users. I need to replace the id-field with a different UUID for each user. After that, I need to make n curl calls with the json as payload. How can I achieve this?
My json ...
0
votes
2
answers
181
views
Find files in git that have entry in .editorconfig
I want to find all of the files in git that have some extensions. The list of extensions is generated from my .editorconfig file.
Say I have a list of file extensions such as:
.css
.html
.java
.js
(...
0
votes
1
answer
733
views
Why does `xargs` not work with `echo` but work with `ls`?
root@home:~$ ls
root@home:~$ echo abc > z1
root@home:~$ echo xyz > z2
root@home:~$ ls
z1 z2
root@home:~$ ls | xargs -I{} cat {}
abc
xyz
root@home:~$ echo z1 z2 | xargs -I{} cat {}
cat: 'z1 z2': ...
0
votes
1
answer
467
views
grep for lines in shell script, send to xargs with $1 set
I have a shell script (I use GNU bash 4.4.20 on Ubuntu 18.04) with a list of commands I often run, e.g.:
sudo program1 $1 foo arg1
sudo program2 $1 foo arg2
sudo program1 $1 bar arg3
sudo program2 $1 ...
1
vote
2
answers
214
views
Generalized chmod function differentiating between directories and files (i.e.: with find)
Is there a generalized bash function available that mimics chmod in every aspect, except that it also let's me differentiate between files and directories?
I know there's already numerous examples ...
2
votes
1
answer
1k
views
How to batch delete the redis keys from local machine and through a jump machine inside kubernetes cluster?
I need to delete some keys in my redis cluster which can only be accessed from a jump machine deployed in the kubernetes cluster.
So if I know the key I can delete it by the following command without ...
0
votes
1
answer
359
views
awk multiple commands and multiple args
I'm trying to turn this output:
❯ hg branches -T'{node} {branch}\n'
4b0826975cb29da26a6dd13f463241463c43c6a7 maria
5c31751cdb774f8b6337b6f64232b15903530997 default
Into these commands:
hg bookmark -r ...