Questions tagged [xargs]

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input.

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input. Under the Linux kernel before version 2.6.23, arbitrarily long lists of parameters could not be passed to a command, so xargs breaks the list of arguments into sublists small enough to be acceptable.

xargs often covers the same functionality as the backquote(`) feature of many shells, but is more flexible and often also safer, especially if there are blanks or special characters in the input. It is a good companion for commands that output long lists of files like find, locate and grep, but only if you use -0, since xargs without -0 deals badly with file names containing ', " and space.

1303 questions
-1
votes
1 answer

How to copy all files by single extension

I have list of files a.xxx a.yyy. a.zzz I need copy all files by select by extension for example ls *.xxx | xargs cp a.* dir I write such code ls mysql/db/*.MYD | xargs -n1 basename | sed 's/\.MYD//g' | xargs -i cp mysql/db/{}.* new_folder but get…
kusanagi
  • 14,296
  • 20
  • 86
  • 111
-1
votes
1 answer

File name too long error with command 'stat'

I retrieve a booklist after seaching the python books in home directory using command find ~ -type f -iregex '.*python.*\.pdf' the booklist ... .../Computing/Python/Beginning_Python.pdf …
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
-1
votes
1 answer

What does 'c' mean in Bash commands like args and grep?

echo "^[$*]*[$5][$*]*$" |xargs -I c grep -i c words| grep -i ".....*"| grep - iv "...........*"| sort -f >list Can anyone tell me what the c means after xarg and grep? important note: words is a document containing words
-1
votes
3 answers

Filename match and export

I have several files in a folder. I have to match the filenames using a regex pattern. In the regex pattern I have a word which would be a variable. I want all the files matched with the pattern to be moved to a separate directory with an alternate…
Gopikrishnan R
  • 11
  • 1
  • 1
  • 4
-1
votes
1 answer

Can I get the iterator / iterated variable from xargs?

./script1 | xargs -L1 ./script2 {} script1 gives me lines of output, I want to pass each line of output into script2. Right now, it's running script2 without any parameters. How do I give script2 the values of each line that xargs gets?. I thought…
-1
votes
1 answer

how to export ssl key , crt and CA from httpd.conf apache to use it into nginx for all users

use custom setup that use nginx as web engine with cpanel need command to export ssl files to use it into nginx cpanel now use AutoSSL powered by Comodo that give it free and will renew it automatic when any users domains ssl expire example…
Mikel Tawfik
  • 658
  • 3
  • 9
  • 23
-1
votes
1 answer

How do I use a for-each loop to remove all .php files into 0777 folders

The following command attempts to delete all .php files in / if folder permission 0777 find / -type f -perm 0777 -exec rm -rf *.php \; -exec rm -rf *.html \; with find / -type d -perm 0777 -print0 | xargs -0 rm -rf *.php it's delete folder…
Mikel Tawfik
  • 658
  • 3
  • 9
  • 23
-1
votes
4 answers

optimize xargs argument enumeration

Can this usage of xargs argument enumaration be optimized better? The aim is to inject single argument in the middle of the actual command. I do: echo {1..3} | xargs -I{} sh -c 'for i in {};do echo line $i here;done' or echo {1..3} | for i in…
Trebor
  • 23
  • 3
-1
votes
1 answer

Whoami and xargs

I need help trying run whoami and get userid and then run df -k to find all filesystem that are own by userid. The following command I have, but does not work. whoami | awk '{print $1}' | xargs -I '{}' df -k | grep '{}'
-1
votes
1 answer

Inserting delays using curl for url unshortening

I am using the following script to unshorten urls in my file : shortened_urls.txt cat shortened_urls.txt | xargs -n 1 curl -x 23.100.73.22 samemon:PasSworD@myprivateproxy.net:15213 -Ls -I -o /dev/null -w %{url_effective}'\n' > unshortened.txt…
-1
votes
1 answer

Bash syntax error in CIS document

I'm working on implementing changes as required by CIS standards for section 9.1.12 (CentOS 6.) The following command returns a syntax error: df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -group -ls The error I get…
Mike D
  • 365
  • 6
  • 16
-1
votes
1 answer

Usage of xargs and find

I have following problem. I want to print content of several files. Each file is in different directory, and also has same name. /home/User1/data.txt /home/User2/data.txt /home/User3/data.txt Every file contains single string. I want to achieve…
user2178946
  • 9
  • 1
  • 2
-2
votes
4 answers

Linux find files with string and replace

I have some websites that have been attacked and infected with malware. There are 800+ files that need to be updated and the string is exactly the same in each file. What I want to do is find all the files that have the malware, and then delete the…
php-b-grader
  • 3,191
  • 11
  • 42
  • 53
-2
votes
2 answers

Fetching most recent file and deleting it via adb

I'm trying to do a pipe operation on my Android device through adb (this is for an automated script). The operation is to fetch the most recently modified file in a particular directory and then delete it. Let us say this file is file.txt and it is…
nj2237
  • 1,220
  • 3
  • 21
  • 25
-2
votes
1 answer

using xargs with output piped to awk throws syntax error

Team, I read many posts but its unclear to me.. I need to understand how to deal with this.. I have xargs doing some evaluation and then am piping to awk but get syntax error file.log node1, node2, node3, failing expression with xargs and awk cat…
AhmFM
  • 1,552
  • 3
  • 23
  • 53
1 2 3
86
87