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
3answers
83 views

How do I tar all files without paths

I want to find all .c files in current directory and subdirectories and tar them. I try to use the following way to achieve this goal but when i unzip files, the files in different folders. I don't ...
-1
votes
2answers
57 views

Why does xargs output results with new line characters?

When executing the command find . -maxdepth 1 -regextype posix-egrep -regex '.*/[a-zA-Z]+\.txt, it returns the following results. ./testfile.txt ./testread.txt In contrast the the command find . -...
2
votes
6answers
341 views

How could I improve this script which sorts files according to extension?

I have a small script which simply shall go through my Downloads folder and then sort the files according to the extension. How can I make this cleaner/better? I would like to simply maintain a list ...
0
votes
3answers
78 views

Run find on find

I did a web seach for "linux run find on find" but it produced no relevant results. I want to build list of files by find and then run find again on that list. After fixing some "silly" mistakes I ...
0
votes
1answer
50 views

Why does `ls | xargs wc -l` format prettily?

Running wc -l (line count) individually on a file gives: λ wc -l pacman_Qemq.txt 235 pacman_Qemq.txt But running ls | xargs wc -l gives: λ ls | xargs wc -l 242409 pacman_database.tar.bz2 235 ...
0
votes
1answer
25 views

Replace split with explode in all PHP files

How can I replace the obsolete split PHP command with explode in a folder structure with many files?
0
votes
1answer
50 views

Chaining commands with xargs

I am trying to accomplish the following result with bash: grep files for some substring. take the filenames (which can contain spaces) for these files and print them. after printing each filename I ...
0
votes
1answer
37 views

Use columns in a file as output file variable names

head testregions.bed 21 15390708 21 15890068 16388793 21 16390041 16888505 21 16889055 17388185 21 17388731 17886839 I wanted to use each ...
0
votes
2answers
75 views

bash cat: invalid option — 'r'

Searched every for the invalid option -r for the cat command on our RedHat enterprise 7.7 Maipo (???) server, but no luck. Attempting to read in a list of file names with full path, open the file ...
0
votes
0answers
25 views

xargs not behaving as expected with input delimited by newlines

I want to run the same command on multiple lines of input. Gnu xargs seemed an obvious fit however it is not behaving as I would expect. When I feed it multi-line input with -d '\n' the input lines ...
2
votes
1answer
45 views

Unzipping many files in many subdirectories

BACKGROUND A directory can N-sub directories. Each sub directory contains multiple .rar files to be unzipped. ~/mydi r/Data 1 ~/mydi r/Data2 ... ~/mydi r/DataN note the space between the 'i' and '...
1
vote
2answers
39 views

Mac OS xargs combine original argument with new arguments

I am able to list audio files with the complete path: (using '-onlyin' for testing) $ mdfind -0 -onlyin ~/Music kind:audio | xargs -0 -n 1 /Users/rrasch/Music/iTunes/iTunes Media/Music/Unknown ...
1
vote
2answers
94 views

How to retain newlines on xargs -I {}

The following extracts a few dozens of lines into a variable, but they are somehow all placed together into a single line. That is, they loose the original newline character: ALL_FOUND_LINES=$(find "$...
0
votes
1answer
42 views

Pass positional arguments

I'm pretty new to xargs I have a command kubectl taint nodes xx.xx.xx.xx dedicated=test:NoSchedule --overwrite=true I have my command , how do i pass the positional values to xargs? they are not ...
0
votes
1answer
39 views

Bash to launching multiple queries with Xargs

I would like something similar to this: cat infile | xargs -I {} -P3 curl {} -o /dev/null --silent --head --write-out "%{http_code} {}\n" > outfile but with this script (that is, include xargs to ...
0
votes
1answer
32 views

What is a sensible way to pipe the first argument and all proceeding arguments separately

Problem I have a command which I alias as a convenience where I annoyingly need to use -- to specify some additional parameters after the call to the command. Take the example below, the command is ...
1
vote
1answer
25 views

Executing stdout results line by line that has a prompt confirmation

I have a command that (potentially) prints several lines and then I want to execute them one by one (using xargs for example, or anything else): find . -name "*string*" -print | awk '{ print "echo " $...
0
votes
0answers
34 views

To shred recursively, sorting alphanumerically

I want to shred permanently and recursively, but sorting firstly numerically and then alphabetically. The command shredded in wrong order/sort, for example: shred: ./browser/tabwidget/tabwidget.cpp: ...
0
votes
1answer
33 views

Why does xargs seem to handle delimiters differently if -I is set

xargs -n1 -I '{}' echo '{}' <<< "foo bar baz" prints foo bar baz while xargs -n1 echo <<< "foo bar baz" prints foo bar baz What causes this behavior?
6
votes
3answers
75 views

Command that copy files with given time stamp

We need a command that copy files from current directory to another with given date. -rw-r----- 1 schmidt schmidt 276423 set 03 10:31 'event01.csv' -rw-r----- 1 schmidt schmidt 283861 set 03 10:34 '...
2
votes
2answers
116 views

Coping with filenames starting with a dash (“-”) when using `-exec` and `xargs`

I am following this question though some of the file names here contain a dash at the beginning of the filename. This is interpreted as an additional option for cp. Following another question (on ...
0
votes
2answers
38 views

How to append arguments to the command xargs is executing? (host command for instance)

I am writing a dns tool and require "| xargs host" and this works however the host command is doing the lookups agains the dns servers configured in /etc/resolv.conf. I was running some tests and ...
2
votes
2answers
110 views

xargs combined with bash -c with multiple placeholders

I am combining ls, xargs and bash -c to run a specific program on multiple input files (whose names match the pattern barcode0[1-4].fastq. The program that I am calling with xargs is called krocus ...
2
votes
1answer
71 views

Compare archlinux package size and popularities

I have this command: $ expac -SsH M "%m: %n$\t%d" lynx | sort -h | tr '$' '\n' 7.24 MiB: links A text WWW browser, similar to Lynx 4.99 MiB: lynx A text browser for the World Wide Web Which ...
0
votes
2answers
43 views

How to find and copy only the first 100 .jpg files under the home directory, including all the subdirectories within?

I coded like below: $ find . -maxdepth 1 -name '*.jpg' | head -n 100 | xargs -0 {} cp {} /home/rachael/backup Error showed: xargs: {}: No such file or directory What's wrong with my code and how ...
0
votes
2answers
70 views

How could I untar many tar files seperately with one command?

I have many tar files like this: aa.tar, bb.tar, cc.tar, .... I would like to untar them to their own directories such as aa/, bb/, cc/ ... I tried this: ls | xargs -n1 -I {} tar -xvf {} -C `...
0
votes
3answers
47 views

Quotes are being treated differently in backtick output [duplicate]

Background I want to pass a list of filenames (listed via find) containing spaces to my custom python script. Therefore, I set up find to add quotes around each result: find ./testdata -type f -...
2
votes
3answers
57 views

Splitting a file into two variables for piping to one command

I have a JSON object. it has two fields; { href: string, filename: string }. I want to download a file from href, and set its name to $FILENAME.pdf. This happens in a loop How can I do that? ...
1
vote
1answer
63 views

“xargs” error regarding mates files vs singles files

I'm currently working with HISAT2 and am trying to use xargs to make my life easier when inputting multiple samples. So I have a text file "samples.txt" which has each sample name separated by spaces-...
0
votes
0answers
45 views

Xargs and cd command [duplicate]

Can someone can explain me why the code below: echo "dir1" | xargs cd doesn't actually change working dir to dir1? It just return an error:xargs: cd: No such file or directory. Shouldn't the xargs ...
0
votes
1answer
262 views

multi threaded find exec

Is there some mechanism to make find with -exec use multiple jobs? Lets use this command for example find ./* -exec flac --best {} \; Is there some way to set the number of concurrent -exec ...
3
votes
1answer
109 views

Combining xargs, sed and command substitution [duplicate]

I would expect under bash for the following: ls *.py | xargs -I{} echo $(echo {} | sed 's/\.py/_2\.py/g') to list all .py files contained in the directory but with _2 annexed after the file name ...
1
vote
2answers
84 views

Copy the same file to the desktops of all users

I’m looking for a way to copy a file to all Desktops directory of each user. Something like: cp myfile /home/*/Desktop/ I found a way to copy files to all home directories using xargs but it fails ...
0
votes
0answers
54 views

Prevent xargs from appending a dot at the end of the term

I am trying to use the gdrive command line app via a script. The output of gdrive is whitespace delimited, and I need to process further the first term (which is a filename) of the output with a ...
3
votes
2answers
265 views

Filter columns in string with awk piped with xargs

I have some files: file1.csv file2.csv file3.csv A given script processes them, logging to this file: my.log with this format: (filename col2 col3): file1.csv 1 a file2.csv 1 a file3.csv 1 a ...
2
votes
1answer
108 views

Using sed with xargs [duplicate]

echo './2d41d907b7cb558db6f3ca49e992ad8/rendering/02.png' | xargs -I {} cp {} `echo {} | sed s'/\///g' ` This gives me an error saying cp: './2d41d907b7cb558db6f3ca49e992ad8/rendering/02.png' and '....
2
votes
2answers
170 views

/usr/bin/truncate: Argument list too long

I want to use the truncate command to create a huge number of small files for testing. I tried the command with a small number of files (100) and it worked. When I changed the number to 1000000, it ...
1
vote
1answer
55 views

Mac OS xargs adds '?[m' at the end of line

I am trying to delete some local git branches with git branch -D $(git branch | grep 'RTL-1[1|2|3]' | xargs) However I am getting this kind of error error: branch 'RTL-1114_branch_name1?[m' not ...
1
vote
1answer
38 views

Pipe inputs from more than 1 process

I am trying to automate some make commands. Along with the target we have a variable that is passed to make (corresponding to set of a #ifdef's in code). The make command looks like this: make <...
0
votes
0answers
47 views

Uninstall list of packages with xargs command and confirmation input

I have a long command expac --timefmt='%Y-%m-%d %T' '%l\t%n'|sort -n | awk -F"\t" -v "Date=$(date -d'2019-08-14 12:59:00' '+%Y-%m-%d %H:%M:%S')" '$1 > Date {print $0}' | cut -f2 | xargs sudo ...
4
votes
2answers
187 views

Get city location from IP addresses inside a file

What a i need is to find the city associated with each IP address, I've stored them inside a file. For example, the file's content is: 99.203.11.34 99.203.11.37 99.203.11.47 99.203.11.51 99.203.11....
0
votes
1answer
38 views

xargs with multiple commands and max-args

I have a program that requires arbitrary number of files. It works like ./code output.txt file1 file2 file3 And I have thousand of input files for it: file1, file2, ..., file1000. However I can ...
1
vote
1answer
112 views

xargs does not end after reaching EOF

I use this bash command: cat urls.txt | xargs -d $"\n" -n 1 -P 250 php script.php $1 When it reaches the end of file for urls.txt it does nothing. My script if it's matter does connect to websites ...
0
votes
2answers
166 views

redirecting `ls` output to another command with xargs

In the directory I am working on I have two files with the extension .sam: PD180425_aligned_minimap.sam PD180793_aligned_minimap.sam For each of these two files, I need to apply a command that looks ...
4
votes
1answer
181 views

Why xargs uses -t to enable verbose mode?

Most programs use -v to enable verbose mode. Why does the GNU xargs use -t to enable verbosity?
0
votes
1answer
89 views

Pass piped command line to xargs

I have this command line: curl https://token-api/42 | awk '{ print $0 }' which produces this output: {"id":"PX-12345","expiresAtUtc":"2020-07-05T06:55:52","createdUtc":"2019-07-15T06:55:52"} The ...
1
vote
1answer
110 views

Preserve order of outputs of commands executed in parallel by xargs

When I run a command with xargs -n 1 -P 0 for parallel execution, the output is all jumbled. Is there a way to do parallel execution, but make sure that the entire output of the first execution is ...
0
votes
1answer
59 views

modify output of command to input as a variable to another

I am trying to modify the output of a command , store it to a variable and pass it to another command in a single line. I tried using xargs, but didnt work well. hre is the first command echo "DIS ...
2
votes
2answers
156 views

find - how do i make an alias to do something like (find . -iname '*$1*')?

I have a findn function: findn () { find . -iname "*$1*" } Using this function has one downside that I cannot use -print0 | xargs -0 command (I am using mac) following findn filename to extend ...
0
votes
0answers
7 views

xargs does not process replace-str if -L is specified? [duplicate]

The following example shows that xargs does not properly process the replace-str (either default or custom) if -L is specified. Is this intended behavior? The man page says -I implies L 1 but not ...