utility in Unix-like operating systems for passing large numbers of arguments to programs that can only take a small number of arguments
2
votes
2answers
34 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
38 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 ...
1
vote
3answers
50 views
Using Xargs with hocr2pdf
I'm trying to use tesseract and hocr2pdf on a series of .tif files in a folder.
Using ls *.tif | xargs -I% tesseract % % -l fra hocr produces the html files which have the same file name but with ...
0
votes
1answer
32 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 ...
0
votes
2answers
41 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 ...
0
votes
2answers
57 views
xargs -I behaviour
A variable var contains multiple arguments, each split by a new line.
echo "$var" | xargs -I % echo ABC %
#Results in:
#ABC One
#ABC Two
#ABC Three
However, when omitting -I and the % characters, I ...
1
vote
3answers
217 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 ...
0
votes
2answers
27 views
Change attributes of all symlink targets in a directory
How to change attributes of all symlink targets inside a directory ?
/usr/bin/find /mydir -type l | xargs /bin/readlink | /usr/bin/chattr +s
piping three commands wont works.
Thanks.
2
votes
3answers
81 views
Using find, xargs, etc. to output similarly named files
I have a folder full of HTML files:
001.htm
002.htm
003.htm
…
I want to run Pandoc on them to convert them to similarly named Markdown files:
001.md
002.md
003.md
This command works on one of ...
0
votes
1answer
94 views
Use java and xargs(?) to supply only arguments to java program and not replace stdin
I have a written a small java program that takes arguments from the commandline and should then be interactive.
When I want to test with large input I want to pipe the contents of a file to the JVM ...
2
votes
3answers
170 views
sudo to kill output of ps, awk, xargs
I want to kill root owned processes containing foo in the process name
sudo sh -c "ps aux | grep [f]oo | awk '{print $2}' | xargs kill -15"
this command fail as awk and xargs are ignored.
sudo sh ...
0
votes
2answers
68 views
piping output of find to xargs wc gives unreasonable totals
In a project with thousands of files, I wanted to compare total lines-of-code, to lines-of-code just in PHP (discarding CSS, JS, etc).
When I run
find . -type f | xargs wc -l
I the total on the ...
0
votes
3answers
76 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
64 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
0
votes
2answers
179 views
cURL or xargs: show progress
I am using cURL to download many files and concatenate them to STDOUT. About 100,000 small files. I would like to see progress against the 100,000. Is this possible with curl or by using curl into ...
3
votes
2answers
173 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.
...
0
votes
4answers
96 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
175 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*' ...
0
votes
2answers
87 views
find -print0 | xargs -0 grep not working as expected on Ubuntu 10.04
I've got a bit of a weird issue.
If I run:
find . -iname '*.php' -o -iname '*.pl' -o -iname '*.html' | xargs grep -i users
I get a load of errors for filenames containing spaces, but also some ...
0
votes
2answers
177 views
xargs and cp: find-style “{}+” multiple expansion?
I'd like to copy a group of files to destination folder. But without needing to spawn a new instance of cp for each operation.
The arg format for cp seems to be:
cp src_file1 src_file2 src_file3 ...
2
votes
1answer
373 views
grep, xargs, sed to clean up PHP eval hack
I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
0
votes
3answers
88 views
Passing multiple sets of arguments to a command
instances contains several whitespace separated strings, as does snapshots.
I want to run the command below, with each instance-snapshot pair.
ec2-attach-volume --instance $instances --device ...
2
votes
3answers
142 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
226 views
Replacement for xargs -d in osx
In Linux, you can use xargs -d, to quickly run the hostname command against four different servers with sequential names as follows:
echo -n 1,2,3,4 |xargs -d, -I{} ssh root@www{}.example.com ...
3
votes
3answers
123 views
xargs argument redirection
This seems to be a trivial problem but the solution eludes me ever so cautiously.
I want to clear out many text files; log files. Reason? To save on disk space.
With one text file, this is as ...
0
votes
1answer
60 views
Control mplayer ran by xargs
I feed mplayer with file list from another command:
beet ls somequery -p | xargs -d '\n' mplayer
When invoked this way, mplayer doesn't react on any standard keys, all I can do is to C-c interrupt ...
1
vote
2answers
89 views
Issue using xargs in Linux
I am attempting to pipe the output from youtube-dl to xargs as I would like to name the downloaded file with the title extracted from the first command. however am having trouble doing so. The command ...
0
votes
3answers
2k 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
2answers
196 views
xargs split incoming line
I have a file with two columns separated by spaces like this:
potato 5
apple 7
pretzel 9
I want to issue a command on each line like this:
cmd -f potato -n 5
cmd -f apple -n 7
cmd -f pretzel -n 9
...
1
vote
5answers
1k views
Pipe output of awk to kill -9
I'm trying to kill any process that has to do with mysql. I'm piecing together a command, and so far, haven't come up with the right solution. One other consideration, is that the last process will ...
1
vote
1answer
641 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
481 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 ...
0
votes
2answers
131 views
flexible number of agruments with xargs
Is it possible to specify the number of arguments that xargs takes without doing it explicitly with -n option, but implicitly with a delimiter, so that the single parameters would be delimited with a ...
7
votes
6answers
2k views
How can I use two parameters at once with xargs?
I need to convert videos but I don't know where are they, so I need to find them. How can I give the result and an output file name to ffmpeg with xargs ?
I already find out that I can construct the ...
5
votes
2answers
3k views
using John the Ripper to recover RAR password
Testing John the Ripper in Mac OS X as a RAR password recovery solution, but xargs gives me an error:
john --incremental:all --stdout | xargs -I jtr unrar e -pjtr -inul test2.rar | grep 100%
xargs: ...
0
votes
3answers
296 views
Run xargs on the first word on a line
Is there a way to run xargs on only the first argument of a line? So if my input is the default output from a grep, like this:
./file1 "matching string"
./file2 "matching 2"
What I want ...
1
vote
2answers
149 views
xargs touch followed by second command
I am randomly selecting files from a directory that I want to process, and I want to apply the touch command to them so that I know the last one that's been visualized, then apply the visualization ...
0
votes
1answer
50 views
How do I grep for foo && !bar?
I want to output all the lines in my source code which contain the string foo but don't contain the string bar. I tried this:
find . -name "*.[hc]pp" | xargs grep -n foo | grep -x bar
However ...
2
votes
1answer
728 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? ;-)
2
votes
3answers
450 views
combining sed with xargs to obtain a source and output file name
I have a situation where I have some input files like this:
M2U0001.MPG
M2U0180.MPG
And I want to run a command (in a bash shell) on each similarly named file in the directory. I'd like the ...
1
vote
2answers
423 views
File name with spaces piped to two xargs commands
I have a directory and many more subdirectories like the following -
file with spaces.txt
filewithsuperlonglines.txt
ordinaryfile.txt
binaryfile.bin
The command -
find . -type f -print0 | ...
1
vote
2answers
758 views
Remove all except one file and directory at path
I need to remove all the files in a directory except for one file and one folder. Up to the grep I can output the correct list of items I want to remove but when i add xags, nothing is deleted.
this ...
0
votes
1answer
161 views
find xargs and curl give an error with -C- option
This command works fine
find ~/mypath -name *.fstq -print|xargs curl -u sdd:dsdsd ftp://ftp.dsdd.nsdh.com/sdsds/ -T
but when I add
find ~/mypath -name *.fstq -print|xargs curl -C- -u sdd:dsdsd ...
0
votes
2answers
150 views
Efficiently stripe incoming one-word lines onto columns?
Consider a stream of one-word lines such as the stdout of
$ echo foo bar baz quux xyxxy thud | tr ' ' '\n'
foo
bar
baz
quux
xyxxy
thud
I say "one-word" to indicate there is no whitespace other than ...
1
vote
2answers
134 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 ...
3
votes
3answers
827 views
How can I grep in source files for some text?
At the moment I'm using two commands, I'm sure there must be a better way...
wim@wim-acer:~/ffmpeg$ find . -name "*.h" -print0 | xargs -0 grep -i invalid\ preset
wim@wim-acer:~/ffmpeg$ find . -name ...
1
vote
2answers
2k views
How to feed grep output into scp?
I have a file where each line is a file name. Content of the file:
file1
file2
file3
...
I then run a grep command to get a subset of the list of the file names.
How do I feed the output of the ...
0
votes
2answers
87 views
Multiple find by xargs
I have a problem; 1) I'm using find command to find directories; 2) I need to execute another find command in previously found directories.
I'want something like this find . -type d -not -name bad | ...
1
vote
1answer
194 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 * ...
3
votes
4answers
3k views
What is a Linux command to find files containing some strings but not another?
I'm trying to search a lot of XML files for certain strings but not other strings, and I'm having trouble putting a command together to do it. I only want it to list the file names that match the ...