xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option












1














I'd like to count all the ordinary file on home directory with commands:



$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


It prompts



xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


What's the problem with usage?










share|improve this question






















  • Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
    – steeldriver
    3 hours ago


















1














I'd like to count all the ordinary file on home directory with commands:



$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


It prompts



xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


What's the problem with usage?










share|improve this question






















  • Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
    – steeldriver
    3 hours ago
















1












1








1







I'd like to count all the ordinary file on home directory with commands:



$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


It prompts



xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


What's the problem with usage?










share|improve this question













I'd like to count all the ordinary file on home directory with commands:



$ find ~ -type f | xargs echo | wc -w
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


It prompts



xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option


What's the problem with usage?







xargs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









user10726006

663




663












  • Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
    – steeldriver
    3 hours ago




















  • Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
    – steeldriver
    3 hours ago


















Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
– steeldriver
3 hours ago






Do you really want to count the total number of words in all the filenames, or do you actually want to count the number of files? if the latter, then you can avoid processing the names altogether e.g. find ~ -type f -printf 1 | wc -c (print a single - arbitrary - character for each file, and count those)
– steeldriver
3 hours ago












1 Answer
1






active

oldest

votes


















3














It appears that some of your filenames have apostrophes (single quote) in their names.



Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (00) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.



So, what you really want is:



 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w


Read man find;man xargs.






share|improve this answer





















  • find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
    – pim
    3 hours ago












  • @pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
    – Sergiy Kolodyazhnyy
    27 mins ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106805%2fxargs-unmatched-single-quote-by-default-quotes-are-special-to-xargs-unless-you%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














It appears that some of your filenames have apostrophes (single quote) in their names.



Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (00) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.



So, what you really want is:



 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w


Read man find;man xargs.






share|improve this answer





















  • find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
    – pim
    3 hours ago












  • @pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
    – Sergiy Kolodyazhnyy
    27 mins ago
















3














It appears that some of your filenames have apostrophes (single quote) in their names.



Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (00) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.



So, what you really want is:



 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w


Read man find;man xargs.






share|improve this answer





















  • find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
    – pim
    3 hours ago












  • @pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
    – Sergiy Kolodyazhnyy
    27 mins ago














3












3








3






It appears that some of your filenames have apostrophes (single quote) in their names.



Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (00) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.



So, what you really want is:



 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w


Read man find;man xargs.






share|improve this answer












It appears that some of your filenames have apostrophes (single quote) in their names.



Luckily, find and xargs have ways around this. find's -print0 option along with xargs's -0 option produce and consume a list of filenames separated by the NUL (00) character. Filenames in Linux may contain ANY character, EXCEPT NUL and /.



So, what you really want is:



 find ~ -type f -print0 | xargs -0 --no-run-if-empty wc -w


Read man find;man xargs.







share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









waltinator

21.9k74169




21.9k74169












  • find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
    – pim
    3 hours ago












  • @pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
    – Sergiy Kolodyazhnyy
    27 mins ago


















  • find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
    – pim
    3 hours ago












  • @pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
    – Sergiy Kolodyazhnyy
    27 mins ago
















find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
– pim
3 hours ago






find ~ -type f | wc -l will work with more files, since xargs put all arguments on one command line and there is a limit in the number of args.
– pim
3 hours ago














@pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
27 mins ago




@pim While it may be correct that xargs can suffer from argument list too long error, in this answer -print0 and xargs -0 combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
27 mins ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106805%2fxargs-unmatched-single-quote-by-default-quotes-are-special-to-xargs-unless-you%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Understanding the information contained in the Deep Space Network XML data?

Ross-on-Wye

Eastern Orthodox Church