Questions tagged [xargs]

A command that constructs an argument list for a command from text given as xargs' standard input (or read from a specified file) thus allowing execution on the results of a search, for example. It is provided by the findutils package

Filter by
Sorted by
Tagged with
0 votes
1 answer
77 views

grep command to get file list with concatenated custom text

I am trying to list of files' names with custom text(my another command) with it. I am using below command: grep -rl --include=*.php --include=*.html --include=*.js 'ajax.googleapis.com/ajax/libs/...
user avatar
  • 103
0 votes
0 answers
32 views

xargs with rsync results in rsync: link_stat "/mnt/backup_share/A5000_3/......" failed: No such file or directory (2)

I am trying to speed up rsync to backup the folder mounted to /var/lib/docker with xargs the following command works sudo rsync -avzP --delete --recursive --times --perms --links /var/lib/docker /mnt/...
user avatar
0 votes
1 answer
40 views

get xargs to run a command once for each input instead of once with every input

I thought I could run the following find ./ -iname "*\.mkv" | xargs -d "\n" ffprobe -show_streams -i to get codec information for each file, but it appears xargs is trying to pass ...
user avatar
  • 1
0 votes
1 answer
41 views

How to change script for deleting files while names misses symbols?

I am trying remove files by names according this answer How to delete files listed in a text file But get following error: rm: cannot remove 'var/Resources/Images/fd29d33d.jpg'$'\r': No such file or ...
user avatar
  • 131
0 votes
0 answers
109 views

Output of find | xargs not redirecting to log file

I'm developing a Bash script which cleans up old data files periodically, and right now everything works except for the log file I'm trying to generate so I can see what it did. The structure I'm ...
user avatar
0 votes
1 answer
47 views

How to move a matched id of mat files in different folder

I have Matlab (.mat) files in a particular folder. In a text document, I have some IDs list marked as 0 and 1. First I need to match the IDs and separate the mat files that are marked as '1'. For your ...
user avatar
  • 1
2 votes
1 answer
213 views

Delete files not matching pattern using xargs

The following command is from https://www.tecmint.com/xargs-command-examples/ the example #9. It is to delete files not matching *gz from current directory. $ find . -type f -not -name '*gz' -print0 | ...
user avatar
  • 123
0 votes
1 answer
304 views

nohup can't save the pid of the process into file with xargs command

In the script that I am building I am having problem saving the pid to file. If run in the terminal the command below: nohup mvn spring-boot:run > $HOME/logs/app.log 2>&1 & echo $! > $...
user avatar
1 vote
2 answers
177 views

How to add .sh extension to script files in Linux

I have a dozen of files without extention, and I need to add .sh to all the files are a script Bourne-Again shell. How do you achevie that without using sed, awk,... I located the files like so: file *...
user avatar
2 votes
1 answer
1k views

Need to move files found using grep into a folder

As part of a University course, I'm trying to reclusively search for a string in a list of 500 files, and then copy those items found into a new folder. I can find the files without a problem using ...
user avatar
  • 33
0 votes
2 answers
100 views

Linux Command [Requirement] [duplicate]

Can anyone tell me what this command means? I've seen it in a tutorial but can't get it well. find . -type f | xargs file
user avatar
0 votes
1 answer
71 views

How can I pass command output as first argument to next command

I am using Virtualenv in Python, and I have to execute the pip command with sudo because of windows filesystem... executing sudo pip executes the pip outside virtualenv ... so im directly executing ...
user avatar
  • 1
0 votes
3 answers
203 views

How to count files separated by null characters, as returned by; find . -type f -print0?

Extract from man find: -print0 True; print the full file name on the standard output, followed by a null character (instead of the newline character that -print uses). This allows file names that ...
user avatar
  • 3,238
0 votes
1 answer
94 views

Error when trashing oldest files in a directory. (gio trash error when used with xargs)

In 18.04 I was able to find and trash all but the newest n (e.g. 8) files in a directory with: find . -maxdepth 1 -type f | sort -r | sed 1,8d | xargs -d \n gio trash When I try this in a freshly ...
user avatar
  • 3,238
0 votes
2 answers
65 views

Copying a list of test/path/to/files to list of prod/path/to/files

I would like to copy a list of files in the form test/path/to/file/filename.xyz to their corresponding production path prod/path/to/file/filename.xyz. If the test path and the prod path are the same ...
user avatar
  • 101
10 votes
1 answer
3k views

How to pass list of names to be searched by grep using xargs?

I have a text file containing names (nameslist.txt) and I want to read them using cat and pipe the result with xargs to a grep command, so that grep checks the existence of each name that it receives ...
user avatar
0 votes
4 answers
72 views

Script to generate a list of urls from a list of authors

I need to take a list of authors names of which may consist from 1 to 4 words like this Osho Hartmann Nicolai Bird Robert Montgomery Coates Ta-Nehisi and generate URLs like this site.com/word1+word+...
user avatar
2 votes
1 answer
1k views

How to make xargs execute in parallel but show complete output of a single instance at a time?

I am running some query commands in remote host with xargs in parallel which is working efficiently and very well but I have some problem in finding in which host I am getting the query from. Right ...
user avatar
2 votes
1 answer
265 views

Unzip a .zip file to all directories that contain a .php file that contains the text “house” inside?

How to unzip a .zip file to all directories that contain a .php file that contains the text "house" inside? Something like: grep -rl --include='index.php' 'house' /directory/path/of_the_index_file* |...
user avatar
  • 23
3 votes
1 answer
52 views

Removing certain file types that do not contain the hostname in the file name

I am doing a file deployment for multiple machines per site, so it is much easier for me to zip all the files once and deploy to every machine. However I would like to remove the config for all the ...
user avatar
4 votes
1 answer
1k views

xargs: invalid option -- 'o'

I was trying to execute this command to fix yet another error (Unable to use a TTY - input is not a terminal or the right kind of file): kubectl get pods -n foobar | grep baz | awk '{print $1}' | ...
user avatar
  • 163
14 votes
1 answer
10k views

xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

I'd like to count all the ordinary file on home directory with commands: $ find ~ -type f | xargs echo | wc -w xargs: unmatched single quote; by default quotes are special to xargs unless you use the ...
user avatar
6 votes
1 answer
4k views

"-bash: /usr/bin/rename: Argument list too long" [duplicate]

I would like to rename files within each sub-directory by adding the name of the sub-directory. Following the answer from Rename files by adding their parent folder name, I tried: rename 's/(.*)\//$...
user avatar
0 votes
2 answers
2k views

How to list all files where the first line is a blank line

I would like to find all the Java files that have a blank line as the first line of the file. I have the following which simply outputs the first line (and filename) of each file into the output file ...
user avatar
  • 135
0 votes
2 answers
3k views

find: paths must precede expression: )xargs [duplicate]

mkdir dregsfolder find /home/tony/Desktop/unsorted_files/ -maxdepth 1 -not \( -type d -or -iname "*.jpg" -or -iname "*.gif" -or -iname "*.docx" \)xargs -0 --no-run-if-empty mv /home/tony/Desktop/...
user avatar
0 votes
1 answer
2k views

How to copy files from a folder using the find command with the -exec action, or with xargs, to another folder

I'd like to use the find command with the -exec action with the plus (+) sign (for efficiency), or with xargs to copy files from one directory to another. The following answer did not work for me. I'm ...
user avatar
0 votes
1 answer
763 views

create a file in each subdirectory and write its path into it

I'm studying Linux and I've found an interesting exercise. Create a number of directories in ~ (abc, abc/def, abc/xyz, abc/def/ghi/123, abc/def/ghi/456), which is an easy task. After that create a ...
user avatar
  • 263
7 votes
3 answers
4k views

What is the difference between find with -exec and xargs?

trying to learn Bash scripting I want to execute some command on all files below my current directory that satisfy a certain condition. Using find -name *.flac Specifically I want to convert .flac ...
user avatar
0 votes
1 answer
334 views

Can't rename each 'file' to 'file.text' (using xargs)

I have received a task to do these commands on a text file: Choose each second field from the file Sort and choose first 3 unique values Print the contents of each value.text while redirecting ...
user avatar
  • 263
0 votes
1 answer
75 views

Remove files and words

In the moment, when I run git status, I got modified: loanwolf/alerts/locale/fr/LC_MESSAGES/django.mo modified: loanwolf/alerts/locale/fr/LC_MESSAGES/django.po modified: loanwolf/...
user avatar
  • 151
6 votes
2 answers
3k views

Read a URL from a file and open it in a Firefox tab

PreTabs.txt is a file I have on my desktop, and it just contains the line google.com I want to pipe the content of that file into Firefox so that it will open the URL in a new tab. If you execute ...
user avatar
2 votes
0 answers
885 views

Multithread downloading

I have 464 links in txt file, and i want to download them as fast as it is possiblle. Each url is a link to json file. TXT File: http://textuploader.com/ddgry i ve tried cat urls | xargs -n 1 -P ...
user avatar
  • 19
9 votes
1 answer
8k views

How can I solve "unmatched double quote" error using dbus-monitor in combination with xargs?

To intercept (notify-osd) notifications on Linux (Ubuntu), I am using the dbus-monitor script below. Subsequently, the script runs another script (/opt/nonotifs/nonotifs/silent) with the intercepted ...
user avatar
12 votes
3 answers
3k views

deleting folders with spaces in their names using xargs [duplicate]

Why can't xargs delete directories with spaces in their names, and how to fix that? 76 find . -type d |xargs rm -rf 77 rm -rf fire\ hydrant/ 78 rm -rf wine\ glass/ 79 rm -rf tennis\ racket/ 80 ...
user avatar
  • 3,731
2 votes
1 answer
472 views

How to pass to tar.gz a file after rename using xargs?

I'm trying to rename log files and make tar them as 'tar.gz', I ended with below command but it doesn't get the renamed file name from STDIN (output of mv command) and it causes the tar command to ...
user avatar
  • 33.8k
36 votes
4 answers
79k views

What does "xargs grep" do?

I know the grep command and I am learning about the functionalities of xargs, so I read through this page which gives some examples on how to use the xargs command. I am confused by the last example,...
user avatar
  • 1,293
17 votes
1 answer
2k views

Difference between "xargs" and command substitution?

In many cases I use command substitution instead of xargs. For example rm $(ls) is the same as ls | xargs rm What really are the differences between them? I think one of the differences is that ...
user avatar
  • 1,911
5 votes
1 answer
4k views

Does gzip accept stdin?

When i pipe to gzip it can not accept stdin i should using xargsto convert stdin to argument $ls 1.txt $ls |xargs gzip && ls 1.txt.gz every thing is ok . but when i want to compress a cpio ...
user avatar
  • 1,911
1 vote
3 answers
96 views

How do I fix my bash command to make a year-based hierarchy of my photos using symlinks?

I'm new to bash and I'm having problems with using variables in xargs I think. imanuel@orangepipc:~$ find /media/et10000 -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image' | cut -d':' -f1 | ...
user avatar
0 votes
2 answers
4k views

Why does not pipe work with 'find' and 'ls'

Why does not pipe work with 'find' and 'ls' If I do find . -name *foo* | ls -lah , it does a ls on $PWD and not the output of find. The solution however is find . -name *foo* | xargs -r ls -alh or ...
user avatar
1 vote
1 answer
408 views

How can I copy all files and folders from one directory to another with similar structure with `find` and `xargs`?

For example, I use find command find /usr/share/icons -iname 'foxitreader*' find the files: /usr/share/icons/hicolor/32x32/apps/FoxitReader.png /usr/share/icons/hicolor/48x48/apps/FoxitReader.png /...
user avatar
  • 276
2 votes
1 answer
193 views

Elegant way of copying list of directories to target directory

Background: I have started using beets for managing my music collection. It uses the command line as the primary interface. The command beet ls -ap for example emits a list of paths (folders) that ...
user avatar
  • 147
3 votes
0 answers
2k views

fswatch | while read | xargs running command twice

Thanks in advance for any advice I'm working on an fswatch command to launch a script when files hit the Downloads folder. fswatch --event Created Downloads/ | (while read x; do echo $x | xargs -0 ...
user avatar
2 votes
1 answer
597 views

Troubles piping echo output to xargs script for mv command

and thank you in advance for any advice. I'm working on a script that will automatically sort my downloads. The script is very simple, and running it manually has the intended effect. The problem I'm ...
user avatar
0 votes
1 answer
1k views

make clean in several subdirectories

I want to clean several (>20) subdirectories with make clean. I thought about someting like this: find ./ -type d -maxdepth 1 | xargs "make clean" but it doesn't work. Could you please help me?
user avatar
  • 1,346
7 votes
1 answer
20k views

Command to change permissions only on files not directories

I have the following command find . -type f -print0 | xargs -0 chmod 644 which would successfully change to 644 the permissions on all files in ., provided that the filenames contained no embedded ...
user avatar
  • 1,439
2 votes
1 answer
341 views

Bash Command Arguments ${...}

I noticed this type of command argument in a bash script: node ${debug?--nocrankshaft --nolazy --nodead_code_elimination --debug-brk=15454} app.js I am wondering what ${....} means? How is it used?...
user avatar
  • 133
3 votes
1 answer
55 views

Finding, moving and removing in Ubuntu

OS: Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-62-generic x86_64) I have a directory like the following: ~/total/ test1/ test1.txt some_other_file_i_dont_care.py test2/ ...
user avatar
  • 133
32 votes
3 answers
43k views

Piping find -name to xargs results in filenames with spaces not being passed to the command

Normally to remove files with spaces in their filename you would have to run: $ rm "file name" but if I want to remove multiple files, e.g.: $ find . -name "*.txt" | xargs rm This will not delete ...
user avatar
  • 467
2 votes
1 answer
879 views

find command to remove files says that some files don't exist

I have an OSX Mountain Lion Laptop connected to and Ubuntu 11.10 system and tried to copy one .csv file from the OSX machine to the Ubuntu machine. I stopped the file transfer as I realised it created ...
user avatar