Questions tagged [xargs]

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input.

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

How to transform -exec to xargs for better performance in UNIX SHELL?

Sorry, a very simple question. How can I transform the following working code to copy all JSON files to the parent folder, using xargs? The motivation is to work on a lot of files (150K files). find . ...
user7665853's user avatar
0 votes
0 answers
17 views

cat | xargs mkdir: File name too long? [duplicate]

I am trying to make directories from a very simple text file list (folders.txt) that looks like this: Homesteader_Droopy_1954 Car_of_Tomorrow_1951 Dixieland_Droopy_1954 Doggone_Tired_1949 ...
DasKraut's user avatar
  • 103
-1 votes
0 answers
28 views

Shell escape dollar in child process from xargs

If a file contain $ in the value, how can it be escaped. touch 'someFileWith$InItsName.md' find . -type f -print0 | xargs -r0 -n1 -I'filename' bash -c 'f="filename"; echo $f' in the above ...
vito's user avatar
  • 471
0 votes
1 answer
70 views

xargs with multiple arguments and waiting between certain commands

To preface this, I'm completely new to programming and I'm clueless in general. Ok, so I made a script that I will now explain. # Input YouTube video URL into tool that will download the YouTube ...
Hedonium's user avatar
0 votes
1 answer
41 views

How do I prevent xargs from running multiple commands?

I operate on lists of arguments of unknown total lengths in the format of find /home -type f -size +512k -print0 output. The order of the arguments is significant. I need to pass them in a command ...
mossymountain's user avatar
0 votes
3 answers
44 views

passing file names to a script which takes multiple arguments which are modified names of the input file using xargs

I have a script that accepts two files as parameters (run_this file1 file2). I have bunch of files that I select with ls analysis-{A,B,C}*-[123][abc].csv and for each of those I also need to pass the ...
atapaka's user avatar
  • 1,142
0 votes
2 answers
31 views

How do I get and format the contents of a bunch of text files (md5sums) in Linux?

I have a bunch of md5 files, which have a hash and a path/filename. I want to output the hash and filename, but not the path. Example file contents: d7b7494a0602d91b391848dfaebec7ac /home/develop/...
Ben Holness's user avatar
  • 2,383
0 votes
0 answers
41 views

How can I execute each line of a file using xargs and GNU bash 5.2.0(1)-release (aarch64-apple-darwin21.6.0)?

I have a txt file, each line is a bash command. I would like to execute each. I do this on Ubuntu: cat file_with_commands.txt | xargs -P10 -I {} bash -c '{}' and it works. The -P10 flag makes sure up ...
zabop - we're hiring's user avatar
3 votes
3 answers
97 views

When combining tr with null characters and xargs -0, it doesn't work as expected

So, I have a file that contains ~ delimited fields that I need to convert to sql. The catch here is that there are spaces in this data. Generally, this wouldn't be an issue because I could just use ...
Christian Bongiorno's user avatar
0 votes
2 answers
39 views

Is there a way to rename files downloaded with wget when using -i to download from a list of links?

I have a large text file of links that I want to mass download using wget, but the file names are getting extra junk added to them from the url and I want to prevent that. The urls are broadly ...
o-dawgie's user avatar
0 votes
2 answers
60 views

bash xargs for loop having issues with variables and arguments

I have a while loop that calls on xargs to name files based on part of the output. do $CLIPATH/show attributes attr=0x1006e attr=0x3b1090d attr=0x3b10944 attr=0x3b1093e attr=0x3b10943 attr=0x100c5 ...
Musik847's user avatar
2 votes
2 answers
76 views

Pass each line of stdout as stdin to a new invocation of a tool

I would like to pipe each line of stdout into stdin of a separate invocation of another tool - essentially mapping over lines, in bash on the command line. I know I can loop, but that's a bit verbose ...
Cornelius Roemer's user avatar
1 vote
3 answers
83 views

Is there any benefit of executing "| xargs" without any arguments?

I came across scripts where | xargs is executed without any arguments. I started removing such occurrences because scripts just work without them but wanted to verify that I'm not missing something. ...
Alex's user avatar
  • 1,243
-3 votes
1 answer
174 views

How to execute several python scripts in parallel that use 2 GPUs and avoid cuda out of memory?

I have a bash file (generateData.sh) that contains hundred of python scripts such as : python create_video.py input output --param1 --param2 --param3 Each python script processes a different input ...
Florian Delcour's user avatar
0 votes
2 answers
37 views

How can I use wc for each file returned by ls

I am trying to get the following information, given a folder with a lot of folders, get the name of each one with the total number of subfolders without recursivity, in order to do it fast. To do this ...
Tlaloc-ES's user avatar
  • 4,680
0 votes
3 answers
106 views

How to use a sed command on every line in a file?

sed -i -e '/line/a\/to be added/' argument Argument is every line of a file [These lines have path to multiple text files]. Can I use foreach in linux terminal? What are other options? I tried xargs ...
Aishwarya Aishu's user avatar
3 votes
2 answers
108 views

BASH timeout command as xargs command

This is my first post here. I am a hobbyist. I am on an RPi4 running "Raspbian GNU/Linux 10 (buster)". A pipeline gets the power status of a bunch of hard drives. However, on some drives ...
vLAd's user avatar
  • 31
1 vote
2 answers
407 views

Clickhouse-client Code: 36. DB::Exception: Positional options are not supported. (BAD_ARGUMENTS) bash script

Here is my bash script for inserting parquets in parallel to clickhouse. It keeps giving me the error I put in the title though and I don't know why. Any help is appreciated #!/bin/bash time (for ...
Noah Pravecek's user avatar
-1 votes
2 answers
30 views

How to open all files grep finds containing a certain text, recursive

I type grep -r 'something' . and grep finds a lot of hits. Now I want to open all files that were found. I try grep -r 'something' . | xargs vim nothing happens.
Duck's user avatar
  • 34.7k
0 votes
3 answers
75 views

Using grep output as pattern for a second grep

I want to use the output of a grep command as the pattern argument in a second grep. grep "pattern1" file1 | grep [output of previous grep] file2 Desired behaviour is finding lines with ...
Hek's user avatar
  • 21
0 votes
1 answer
41 views

I Can't Figure Out Why I'm Getting These Errors

Errors: ./themezip: line 8: unexpected EOF while looking for matching `'' ./themezip: line 11: syntax error: unexpected end of file My Code: cat ~/scripts/script-files/repos.txt | xargs -I % sh -c ...
SamGreenwood's user avatar
0 votes
1 answer
48 views

Passing a list of filenames to SwiftLint using awk and xargs

Goal I'm trying to introduce SwiftLint to an existing project, in a gradual way, enforcing a "you touched it, you fix it" rule. All changes to the project are done via branches and PRs and ...
Chris's user avatar
  • 3,375
0 votes
3 answers
88 views

Read JSON objects from a file and pass each of them to cURL

I have a file access.log containing timestamps and JSON objects delimited by a newline: 09:52:11 { "key1": "value", "key2": 2, "key3": true }\n 09:52:13 { "...
Ivan's user avatar
  • 29
0 votes
1 answer
77 views

How to force Amazon Elastic Beanstalk get-config to quote all strings when ouputting as YAML

I am exporting all AWS ElasticBeanstalk environment variables and piping the output to serve as command line arguments using xargs. export $(/opt/elasticbeanstalk/bin/get-config --output YAML ...
Favourite Onwuemene's user avatar
0 votes
0 answers
21 views

rsync tries to copy although file is copied

I'm trying to understand the following, maybe one of you guys can help me out by explaining on what exactly happens here: My goal is to write a script, which copies files from the find-command, ...
Marcus's user avatar
  • 13
1 vote
1 answer
46 views

For Loop: Identify Filename Pairs, Input to For Loop

I am attempting to adapt a previously answered question for use in a for loop. I have a folder containing multiple paired file names that need to be provided sequentially as input to a for loop. ...
JVGen's user avatar
  • 313
-1 votes
1 answer
46 views

how to change user password in ubuntu using xargs [closed]

I need to change the password of "vtm" user to "abcd12345" by using xargs command. so I wrote this comman printf "vtm abcd12345 abcd12345" | xargs -t -n1 passwd but I ...
Vitamin's user avatar
  • 21
0 votes
1 answer
47 views

Comparing/diffing tuning files

I have two files which look something like this: #define TUNING_CONST 55 #define OTHER_TUNING_CONST 107 ... and #define TUNING_CONST 65 #define OTHER_TUNING_CONST 93 ... You can think of these as an ...
Charles's user avatar
  • 11.2k
2 votes
1 answer
40 views

Inserting text at specific position in file names which match a pattern

I am editing a large text file called "test.txt" on a Mac. Most lines start with #, but some lines are a tab separated list of fields: val1 val2 val3 val4 val5 val6 val7 ...
shbrainard's user avatar
1 vote
2 answers
90 views

How to use xargs to get elapsed time for running processes

I want get the run times of some processes. Here is what I am doing ps -ef | grep "python3 myTask.py" | awk '{print $2}' | xargs -n1 ps -p {} -o etime I want to get the pids by ps -ef | ...
AbtPst's user avatar
  • 7,708
0 votes
1 answer
28 views

Copy Files Contained in a Text File (MacOS)

I have a text file containing .M4B filenames (including source path). The file names contain spaces and quotes like: /file/source/Ender's Game.m4b /file/source/Ender's Shadow.m4b /file/source/Speaker ...
Saro's user avatar
  • 23
1 vote
2 answers
206 views

xargs how I can specify replace the {} with N inputs?

I would like to do something like following find ./testsrc -type f -print0 | xargs -0 -P4 -n10 -I{} cp --parents {} <dest>/ The cp is just an example of command that expect something after the ...
Wang's user avatar
  • 6,976
0 votes
2 answers
64 views

How to launch a test on every lines of a file in bash?

I have a file that contains lines of the form: ( 1) 0 sec 730 usec ( 2) 0 sec 1 usec ( 3) 0 sec 1 usec . . . (998) 0 sec 1 usec (999) 0 sec 0 usec I would like to only display lines which contains ...
BobDeTunis's user avatar
0 votes
1 answer
39 views

Run a default command when xargs input is empty

the title is quite self explanatory. I'm am writing a bash script that will manage all my packages (update, upgrade every upgrade-able apt and flatpak packages as well as removing the unneeded ones. ...
Johan Daniel's user avatar
1 vote
1 answer
33 views

How can I run du command from a file on RHEL when file has directories with spaces in the names?

On linux, I have a file called dirs.txt. This file has directory names in it, some of which contain embedded blanks. I want to run the du -sh command on each directory name (to get a total usage for ...
user1443098's user avatar
  • 6,239
0 votes
1 answer
75 views

xargs ignoring part of command after &&

I intend to get a comma separated list of files and then pass it as argument to a command using xargs. However it seems xargs ignores the part of command after &&. $ find */build* -printf '%h/%...
Soumya's user avatar
  • 847
0 votes
1 answer
40 views

How to make xargs read input from starting from specific line?

For example I use this command to list all containers of name django project docker ps -q --filter "status = exited" --filter "name = django_project" Problem is that I can't remove ...
MijatTomić's user avatar
1 vote
2 answers
141 views

Using grep and xargs with git to delete multiple branches at once

I've been using some of the Linux tooling on my Windows machine for a little while now, since it comes with the git installation and it's a ton of fun to use. I've been particularly enamored with this ...
Dumas.DED's user avatar
  • 426
1 vote
1 answer
47 views

eyeD3 with find, xargs to set mp3 tag

Once again, attempting to reinvent the wheel - for self learning exercise: audio book file format: filenames : titletag 001 bookname.mp3 : bookname 002 bookname.mp3 : bookname 003 bookname.mp3 :...
Dee's user avatar
  • 191
0 votes
1 answer
51 views

bash-script - don't see last line of file in find command

I wrote script which shows number of lines in .z format files. But it doesn't count last line if where is not end of line character. how can I fix it? ` todays_day=$(date +%d) if ((todays_day==1)); ...
Kid Jeremy's user avatar
0 votes
0 answers
145 views

How to use xargs curl to read lines of a text file in subdirectory and keep downloaded files in subdirectory?

I have several subdirectories within a parent folder, each with a URLs.txt file within the subdirectory. $ ls H3K4me1_assay H3K4me2_assay H3K4me3_assay ... +30 or so more *_assay files Each ...
Steven James's user avatar
0 votes
0 answers
24 views

Issue with Sed no input file when Xgrep

I am trying to create a script which looks for x days old files that have a specific string in it, it then removes it and logs the file it has changed. My way is probably not the best way, but I am ...
WAQ's user avatar
  • 1
0 votes
0 answers
28 views

How to pass a parameter with a blank space to xargs in Linux

We work with Red Hat Linux (version 3.10.0-1160.59.1.el7.x86_6) and we are running into a problem with a process we have that reads data from a text file and then uses that data to pass parameters ...
lsobrino's user avatar
0 votes
1 answer
36 views

passing file names with spaces to imagemagic convert

Say I have the following files: 'CamScanner 11-06-2022 13.04.24_1.jpg' 'CamScanner 11-06-2022 13.04.24_20.jpg' 'CamScanner 11-06-2022 13.04.24_10.jpg' 'CamScanner 11-06-2022 13.04.24_21.jpg' '...
swamp's user avatar
  • 242
0 votes
1 answer
43 views

Why xargs doesn't see delimiters on MacOS?

I'm doing this: $ echo -e "a\nb" | tr "\n" "\0" | xargs -0 -t echo X I'm getting: echo X a b X a b I'm expecting: echo X a X a echo X b X b What am I doing wrong? It's ...
yegor256's user avatar
  • 101k
0 votes
0 answers
21 views

Is it possible to use xargs to pass the output of one command to a custom command from a sourced file?

I've been struggling with chaining aliased commands, is there a way to: run an aliased command pass each line of the output to another aliased commmand? I've been trying to use xargs for this, but ...
EMC's user avatar
  • 1,430
0 votes
0 answers
123 views

Copy kubernetes pod's repository directly to azure storage account

I'm trying to copy pod's repository directly to azure storage account using a pipe. Instead of doing these two commands : kubectl cp my_pod:my_repository/ . -n my_namespace azcopy cp my_repository/ &...
shako's user avatar
  • 55
0 votes
0 answers
20 views

xargs <urls.txt curl -L | grep "Website blocked" - Trying to match the "Website blocked" with the url from the text file

Trying to identify which URLs from the URL text file are blocked by our web filtering system. Any blocked websites show a message containing "Website blocked", the current command works but ...
paolo's user avatar
  • 1
1 vote
3 answers
353 views

How to find all .PNG files and move them in new folders like 1,2,3,4,5.. (one file per folder)

I would like to find .png files in current sub-folders and move them in new folders. I need one .png file, per single folder. Folders needs to be auto-created. I tried something like below, but doesn'...
DEV186516844's user avatar
1 vote
2 answers
333 views

How to count xargs arguments

I'm piping a large file (~5M lines) into xargs that I'm processing in batches using -L to limit to max-lines per command. The command I'm calling with xargs requires not only the arguments (one ...
Justin Giancola's user avatar

1
2 3 4 5
26