0
votes
1answer
35 views

How to copy a list files to a list of directories or subdirectories

I'm trying to figure out how to copy a list of files to a list of subdirectories. eg. I have 300 files to copy into 300 subdirectories - 1 to 1. file1 -> dir1/sub file2 -> dir2/sub file3 ...
0
votes
2answers
70 views

xargs + pv = messed up terminal

if i want a little progress indicator on my long-running operation i can use pipeviewer: ssh pc2 cat some.file | pv -nC reading | gzip --fast | pv zipping > some.file.gz this gives me a fun ...
2
votes
1answer
40 views

Using xargs with $() - operator precedence?

Inspired by this question. The original question, in short, is "How to turn all :2f into - in all files within a folder". e.g. If I have a file ./abc:2fdef it should be renamed into ./abc-def. At ...
0
votes
2answers
94 views

How can I run mogrify over the 3 million JPG files?

I have 3 million JPG files stored in a Linux CentOS 6 server. I want to change quality to %50 file size over 1 megabyte. I wrote this command but got an "argument list too long" error: $ find -type ...
1
vote
2answers
84 views

xargs substition of more than one argument

By default xargs will concatenate many lines of its input and pass then to the specified command. For example: echo -e 'line 1\nline 2\nline 3' | xargs echo results in line 1 line 2 line 3 ...
4
votes
1answer
67 views

Trying to understand xargs

The target is not to list temp/run*.* files. The target is to understand why the second command does not work. First command: find . \( -name 'temp' \) -print0 | xargs -0 -L 1 -I datafind ls -ltr ...
1
vote
1answer
178 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
6
votes
1answer
315 views

xargs --replace/-I for single arguments

I'm trying to use xargs to run a command for each provided argument, but unfortunately the --replace/-I flag doesn't seem to work properly when conjugated with -n. It seems that {} will expand into ...
4
votes
2answers
222 views

Running find and xargs in background

I want to run this command in background because the process could take a long time. How can I send it to a background process? find /tmp/ -type f -mtime +3 | xargs rm -Rf This does not work: find ...
1
vote
3answers
2k views

Argument list too long for xargs/exec

I'm working on a CentOS server and I have to move around and cat together millions of files. I've tried many incarnations of something like the below, but all of them fail with an argument list too ...
4
votes
3answers
308 views

Spawning multiple parallel wgets and storing results in a bash array to be pretty printed when all wgets are done

I have a long list of urls on my own website listed in a carriage return seperated text file. So for instance: http:/www.mysite.com/url1.html http:/www.mysite.com/url2.html ...
2
votes
3answers
212 views

Use xargs to send requests to the same server in parallel with netcat

I am trying to devise a one-liner to send text to a simple echo server - but multiple connections in parallel. This is what I'm trying: echo -e A,B,C,D | xargs -d, -i -P 4 echo {} | nc localhost ...
0
votes
3answers
82 views

How to call the names of directories after passing them all to xargs?

I'm using find to pass all directories to xargs, and the command on each dir by xargs needs to create a new directory for each, looking like dirname_a, so how can this be done? ie find . -type d ...
0
votes
1answer
63 views

Why doesn't this xargs + grep combo work properly?

I have two files, team1.txt and team2.txt team1.txt =========== Alex Bob Charlie David team2.txt =========== Alex Charlie Benjamin Zed Noah I want to output the people who are in both team1 ...
1
vote
2answers
1k views

Redirect strace to file

Am trying to trace apache2. These are the commands i'm trying to run. ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace >> trace.txt I tried (ps auxw | grep sbin/apache | awk ...
1
vote
3answers
889 views

Why doesn't piping grep output into xargs work with color?

I have a strange issue. My grep has colored output, and if I do something like this: grep -lr '80' /etc/apache2/sites-available/|xargs ls I got: ls: cannot access ...
5
votes
5answers
4k views

How can i move files with xargs in linux

I am trying this and its not working ls file_* |xargs mv {} temp/ Any ideas
1
vote
3answers
481 views

what is diff bentween xargs with braces and without in linux

I want to know what is the difference between this ls | xargs rm ls | xargs -i{} rm {} Both are working for me
3
votes
2answers
765 views

How to use wildcards in a xargs-command?

I've got a directory with numbered files, e.g. 1_foo.txt 2_bar.asc 13_test.png, and want to move them into individual directories (e.g. 1, 2 and 13) using as simple a bash command as possible. ...
1
vote
3answers
545 views

Create multiple files and name them from command line

I need to create 300 blank files and put them in a folder on my server then name them from a list in a txt file, I have SSH access, so is it possible to do this using command line?
0
votes
4answers
148 views

how to do grep in the man command of linux using xargs?

I want to grep into a manual of a particular command say man grep |grep 'insensitive'. One of friends told me that It can be done using xargs but I cant seem figure out how. I want to do it using ...
1
vote
3answers
517 views

Difference between xargs /bin/ls and exec ls?

Hi this may be a very newbie question, but why doesnt the xargs /bin/ls work in this case? I thought it was supposed to be faster? Also what are those /fd/3 directories? sh-3.2# find / -name 'GOALS*' ...
2
votes
3answers
278 views

Xargs string interpolation, not by inserting a space

I want to repeat touch ../template/filename where filename comes from find. I want xargs to apply the touch operation, but I dont want it to insert a space like it usually does which derives into: ...
0
votes
3answers
3k views

Using xargs with mv and mkdir command in Linux

I am attempting to create a directory using the command mkdir. However, I would like to move a subset of files into that directory. I understand I can use xargs, however my attempts have failed. For ...
1
vote
1answer
2k views

Executing lines of a file with xargs, using stdout redirection

I have a file that has lines that look like this: "http://api.domain.com/path/to/resource?format=json" > output.xml and I execute the following from my command line: cat file | xargs -L 1 -I {} ...
1
vote
1answer
716 views

Using a Linux/Unix terminal to copy many files to a new location

I'm trying to use the a Linux terminal to copy many files to a new location. I tired the command: sudo locate -i *file_I_want* | xargs cp $1 /place_I_want_everything_copied_to/ Which, gives an ...
4
votes
1answer
3k views

Create symlinks recursively for a whole tree

I am seeking for a command that would re-create a whole tree of files in a different directory. I would prefer to have all symlinks absolute. Can I do that with a find and xargs? ;-)
1
vote
2answers
168 views

Can I simulate ack by using grep with the right combination of options?

I have ack-grep installed on my local machine, and find it indispensable for quickly 'acking' through a codebase when debugging. However, on my cheap shared hosting, there is no ack-grep. One of the ...
1
vote
3answers
436 views

Expanding globs in xargs

I have a directory like this mkdir test cd test touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt I want to run some command such as ls on certain types of files in the directory and have the * ...
0
votes
2answers
770 views

find Argument list too long

I want to search in many many files for a string. I used find /archive/* -print0 | xargs -0 grep 'robert' -sl Is there a simple method to do it ?
4
votes
2answers
2k views

rsync N newest files in a directory

What would be the easiest way to go about rsyncing the n newest files in a directory to a remote server?
1
vote
3answers
9k views

ls -rt (How to list just THE LAST file? e.g. for: | xargs gnome-open)

e.g. directory containing jpeg files: how to easily open just the most recent jpeg in the current directory?
5
votes
2answers
4k views

Grep exits abnormally with code 123 when running rgrep on emacs

Greetings fellow Emacsers I'm running GNU Emacs 23.1.1 on "Ubuntu 10.04.1 LTS" and any search I perform using the built-in M-x rgrep on the standard Linux kernel source code (vanilla) ends ...
1
vote
4answers
161 views

printing matching lines when greping all files in a directory

I'm searching within Java files for some occurrence of a phrase: find . -name '*.java' | xargs grep -l 'string' How do I change this command to print to the shell all of the lines which contain a ...
3
votes
3answers
6k views

How do I use find to copy all found files to a new name in their same directories?

I've got a simple command that does almost what I want. The following will locate all files with a suffix of '_compressed.swf' and copy each into its same directory with a '.bak2' appended: find ...
1
vote
3answers
2k views

xargs vs backtick

More silly questions from the Linux n00b. =D I'm curious about the performance ramifications of using xargs vs. backticks. For example, what's the different between: find ./ -name foo* | xargs rm ...