Comments on: 12 Practical Examples of Linux Xargs Command for Beginners https://www.tecmint.com/xargs-command-examples/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 13 Jul 2023 11:34:48 +0000 hourly 1 By: Malcom https://www.tecmint.com/xargs-command-examples/comment-page-1/#comment-1936905 Tue, 27 Dec 2022 00:30:52 +0000 https://www.tecmint.com/?p=30254#comment-1936905 How to make wc work with xargs, I know wc.

Just wc works fine, note file 3 had space in it ‘file 3‘.

$  wc file*
   9   84  552 file1
   9   82  512 file2
   9   67  508 file 3
  27  233 1572 total

wc command with xargs

$ echo file? 'file 3' | xargs   wc -l 
   9 file1
   9 file2
wc: file: No such file or directory
wc: 3: No such file or directory
$  ls -l file*
-rw-rw-r-- 1  552 Dec 25 08:05  file1
-rw-rw-r-- 1  512 Dec 25 08:06  file2
-rw-rw-r-- 1  508 Dec 25 08:08 'file 3'

$ echo file? 'file 3' | xargs   -I '{}'  wc -l '{}'
wc: 'file1 file2 file 3': No such file or directory

$ echo file? 'file 3' | xargs   -I %  wc -l %
wc: 'file1 file2 file 3': No such file or directory
]]>
By: logan https://www.tecmint.com/xargs-command-examples/comment-page-1/#comment-1850917 Tue, 26 Jul 2022 01:59:31 +0000 https://www.tecmint.com/?p=30254#comment-1850917 Hi Guys,

Just note that with the -I argument option, the xargs command acts like -n1.

Cheers! ;)

]]>
By: Robin A. Meade https://www.tecmint.com/xargs-command-examples/comment-page-1/#comment-1352041 Tue, 11 Aug 2020 00:09:35 +0000 https://www.tecmint.com/?p=30254#comment-1352041 Examples 5, 6, 8, and 11 don’t define the replace-str. They need `-I {}` added.

Examples 5, 6, 11 enclose {} within double quotation marks. The quoting of {} is unnecessary in all mainstream shells, as discussed here https://unix.stackexchange.com/questions/8647 (That discussion is in the context of GNU find, but is equally applicable to xargs.)

]]>
By: Aaron Kili https://www.tecmint.com/xargs-command-examples/comment-page-1/#comment-1334518 Wed, 20 May 2020 07:21:31 +0000 https://www.tecmint.com/?p=30254#comment-1334518 In reply to Gunnar.

@Gunnar

Thanks for your useful feedback. Concerning this: “Also, the output of a command is referred to as stdout NOT stdin, stdin would be the keyboard.” I think it is clearly explained in the article in terms of how xargs works. It reads data from standard input, then generates and executes command lines.

True the output of a command is sent to stdout but when piped to xargs, it considered as std in(please read the xargs man page for more information). In the above examples, we have used the pipe character to enable it to read from standard input, which in this case is the output of another command. We will work on the spell checking and general grammar checking. Thanks once again.

]]>
By: Gunnar https://www.tecmint.com/xargs-command-examples/comment-page-1/#comment-1334419 Tue, 19 May 2020 15:37:09 +0000 https://www.tecmint.com/?p=30254#comment-1334419 Hi guys!

I really like this article, I just really felt the need to point out, this article could use some spell checking and general grammar checking. Also, the output of a command is referred to as stdout NOT stdin, stdin would be the keyboard. So you may want to correct that. So you are instructing xargs to act on the output a command that is stdout i.e. the display.

All the best and keep up the good work amigos!

]]>