I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together find and grep with xargs, I get the following error:
find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar
xargs: unterminated quote
Any suggestions for a more robust usage of xargs?
...
How can I make xargs execute the command exactly once for each line of input given?
It's default behavior is to chunk the lines and execute the command once, passing multiple lines to each instance.
From http://en.wikipedia.org/wiki/Xargs:
find /path -type f -print0 | xargs -0 rm
In this example, find feeds the input of x...
I'm trying to run the following command:
find . -iname '.#*' -print0 | xargs -0 -L 1 foobar
where "foobar" is an alias or function defined in my .bashrc file (in my case, it's a function that takes one parameter). Apparently xargs doesn't recognize these as things it can run. Is there a clever way to remedy this?
...
suppose you have a perl script "foobar.pl" that prints the following to stdout
date -R
and you want to run whatever that perl script outputs as a standalone bash command (don't worry about security problems as this is running in a trusted environment).
How do you get bash to recognize this as a standalone command?
I've tried using x...
Trying to rename a series of files on a linux server. Finding the files I want is easy:
find . -type f -wholename \*.mbox
Of course, being mbox files, some of them have spaces in the names, so it becomes:
find . -type f -wholename \*.mbox -print0
I'm piping to xargs so that I can rename the files:
find . -type f -wholename \*.mbo...
say i have a directory with hi.txt and blah.txt and i execute the following command on a linux-ish command line
ls *.* | xargs -t -i{} echo {}
the output you will see is
echo blah.txt
blah.txt
echo hi.txt
hi.txt
i'd like to redirect the stderr output (say 'echo blah.txt' fails...), leaving only the output from the xargs -t command w...
I want to find a bash command that will let me grep every file in a directory and write the output of that grep to a separate file. My guess would have been to do something like this
ls -1 | xargs -I{} "grep ABC '{}' > '{}'.out"
but, as far as I know, xargs doesn't like the double-quotes. If I remove the double-quotes, however, then...
Hi,
I'm getting frustrated enough that I figured it was time to ask a question.
I'm trying to replace an email address across a website that is hard coded into 1000's of pages. It's on a FreeBSD 6.3 server.
Here is the command I am using:
grep -R --files-with-matches 'Email\@domain.com' . | sort | uniq | xargs perl -pi -e 's/Email\@...
I have the following alias in my .aliases:
alias gi grep -i
and I want to look for foo case-insensitively in all the files that have the string bar in their name:
find -name \*bar\* | xargs gi foo
This is what I get:
xargs: gi: No such file or directory
Is there any way to use aliases in xargs, or do I have to use the full versi...
Hi everyone.
Well i am new to linux shell and i can't understand any regexp :(
Here is my question:
I have a directory called /var/visitors
and under this directory, i have directories like a, b, c, d.
In each of these directories, there is a file called list.xml
and here is the content of list.xml belonging to /var/visitors/a directory...
I want to understand the use of xargs man in Rampion's code:
screen -t man /bin/sh -c 'xargs man || read'
Thanks to Rampion: we do not need cat!
Why do we need xargs in the command?
I understand the xargs -part as follows
cat nothing to xargs
xargs makes a list of man -commands
I have had an idea that xargs makes a list of comm...
What is the practical difference between the following two commands?
Command A
find . -type f -print0 | xargs -0 grep -r masi
Command B
find . -type f -print0 | xargs -0 grep masi
In short, what is the practical benefit of Command A?
...
The page 38 of the book Linux 101 Hacks suggests:
cat url-list.txt | xargs wget –c
I usually do:
for i in `cat url-list.txt`
do
wget -c $i
done
Is there some thing, other than length, where the xargs-technique is superior to the old good for-loop-technique in bash?
Added
The C source code seems to have only one fork. ...
How can you count the number of the character < in your files?
I am trying to count the number of the character "<" in my files, similarly as in Vim by
%s/<//gn
I run
find * -type f | xargs sed 's/<//gn'
I get
sed: -e expression #1, char 7: unknown option to `s'
This error suggests me that Vim's :s -mode is not like SED.
...
I have these files in a directory: y y1 y2 y3
Running this command:
ls y* | xargs -i basename {}|xargs -i sed "s/{}//g"
produces this:
1
2
3
Can someone explain why?! I expected it to produce nothing - running sed four times, once for each file, and removing the file name each time. But actually it looks like it's applying sed w...
tmp-file contains:
database_1
database_2
database_3
I want to run a command like "mysqldump DATABASE > database.sql && gzip database.sql" for each line in the above file.
I've got as far as cat /tmp/database-list | xargs -L 1 mysqldump -u root -p
I guess I want to know how to put the data passed to xargs in more than once (and not j...
Hello,
example use of "xargs" application in Unix can be something like this:
ls | xargs echo
which is the same as (let's say I have "someFile" and "someDir/" in the working dir):
echo someFile someDir
so "xargs" take its "input" and place it "at the end" of the next command (here at the end of echo).
But sometimes I want xargs to...
I'm trying to write a bash command that will delete all files matching a specific pattern - in this case, it's all of the old vmware log files that have built up.
I've tried this command:
find . -name vmware-*.log | xargs rm
However, when I run the command, it chokes up on all of the folders that have spaces in their names. Is there ...
I have process id in a file "pid"
I'd like to kill it.
Something like:
kill -9 <read pid from file>
I tried:
kill -9 `more pid`
but it does not work. I also tried xargs but can't get my head around it.
...
I want to make a list of files of locate's output.
I want scp to take the list.
I am not sure about the syntax.
My attempt with pseudo-code
locate labra | xargs scp {} [email protected]:~/Desktop/
How can you move the files to the destination?
...