xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
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
add a comment |
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
1
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
yesterday
add a comment |
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
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
xargs
asked yesterday
user10726006
713
713
1
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
yesterday
add a comment |
1
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
yesterday
1
1
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
yesterday
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
yesterday
add a comment |
1 Answer
1
active
oldest
votes
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
.
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
yesterday
@pim While it may be correct thatxargs
can suffer from argument list too long error, in this answer-print0
andxargs -0
combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
yesterday
I think the OP's use ofwc -w
may have led you to suppose they want to count the words inside the files - they're actually usingxargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise,find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)
– steeldriver
22 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
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
yesterday
@pim While it may be correct thatxargs
can suffer from argument list too long error, in this answer-print0
andxargs -0
combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
yesterday
I think the OP's use ofwc -w
may have led you to suppose they want to count the words inside the files - they're actually usingxargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise,find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)
– steeldriver
22 hours ago
add a comment |
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
.
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
yesterday
@pim While it may be correct thatxargs
can suffer from argument list too long error, in this answer-print0
andxargs -0
combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
yesterday
I think the OP's use ofwc -w
may have led you to suppose they want to count the words inside the files - they're actually usingxargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise,find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)
– steeldriver
22 hours ago
add a comment |
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
.
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
.
answered yesterday
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
yesterday
@pim While it may be correct thatxargs
can suffer from argument list too long error, in this answer-print0
andxargs -0
combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
yesterday
I think the OP's use ofwc -w
may have led you to suppose they want to count the words inside the files - they're actually usingxargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise,find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)
– steeldriver
22 hours ago
add a comment |
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
yesterday
@pim While it may be correct thatxargs
can suffer from argument list too long error, in this answer-print0
andxargs -0
combination is perfectly acceptable. See unix.stackexchange.com/a/83803/85039
– Sergiy Kolodyazhnyy
yesterday
I think the OP's use ofwc -w
may have led you to suppose they want to count the words inside the files - they're actually usingxargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise,find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)
– steeldriver
22 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
yesterday
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
yesterday
@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
yesterday
@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
yesterday
I think the OP's use of
wc -w
may have led you to suppose they want to count the words inside the files - they're actually using xargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise, find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)– steeldriver
22 hours ago
I think the OP's use of
wc -w
may have led you to suppose they want to count the words inside the files - they're actually using xargs echo | wc -w
which will count the number of words in the file names, which I think is more likely an attempt to count the number of files (although it doesn't take into account that filenames may contain whitespace). (Likewise, find ~ -type f | wc -l
doesn't take into account that filenames may contain newlines.)– steeldriver
22 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
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
yesterday