The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
3
votes
1answer
46 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 ...
2
votes
1answer
112 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}' | ...
4
votes
1answer
2k 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 ...
5
votes
1answer
920 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/(.*)\//$...
0
votes
2answers
107 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 ...
0
votes
2answers
1k 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/...
0
votes
1answer
509 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 ...
0
votes
1answer
79 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 ...
7
votes
3answers
2k 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 ...
0
votes
1answer
154 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 ...
0
votes
1answer
69 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/...
6
votes
2answers
1k 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 ...
2
votes
0answers
220 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 ...
7
votes
1answer
3k 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 ...
11
votes
3answers
1k 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 ...
2
votes
1answer
277 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 ...
25
votes
4answers
39k 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,...
14
votes
1answer
1k 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 ...
4
votes
1answer
2k 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 ...
1
vote
3answers
77 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 | ...
0
votes
1answer
2k 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 ...
1
vote
1answer
344 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 /...
2
votes
1answer
143 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 ...
3
votes
0answers
1k 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 ...
2
votes
1answer
516 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 ...
0
votes
1answer
583 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?
3
votes
1answer
12k 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 ...
2
votes
1answer
262 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?...
3
votes
1answer
52 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/ ...
26
votes
3answers
34k 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 ...
2
votes
1answer
837 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 ...