Find + -printf + sort conflict?
I need to pass a list of sorted, quoted FLAC file names to SoX for concatenation but am having trouble getting sort to work the way I expect it to.
If I use:
find . -maxdepth 1 -type f -iname "*.flac" | sort
I get exactly what I expect:
./01-Lordy.flac
./02-Both Sides Now.flac
./03-Solitary Man.flac
./04-Holly Holy.flac
./05-Cherry Cherry.flac
./06-Kentucky Woman.flac
./07-Sweet Caroline.flac
./08-Thank the Lord for the Nightime.flac
./09-And the Singer Sings His Song.flac
./10-Brother Loves Traveling Salvation Show.flac
However, I can't really use that for what I'm doing since I need a quoted list with no newlines. I know -printf can do that for me, but when I try:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" " | sort
I wind up with a list of file names that are quoted and separated by a single space (good!) but they aren't sorted (bad!). Or at least they aren't sorted the way I expect them to be:
"./08-Thank the Lord for the Nightime.flac" "./03-Solitary Man.flac" "./09-And the Singer Sings His Song.flac" "./05-Cherry Cherry.flac" "./06-Kentucky Woman.flac" "./10-Brother Loves Traveling Salvation Show.flac" "./07-Sweet Caroline.flac" "./02-Both Sides Now.flac" "./01-Lordy.flac" "./04-Holly Holy.flac"
Maybe even weirder, if I just for the sake of testing use the same code but add a newline:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" "\n | sort
The sort works even if the output is back to not being what I need:
"./01-Lordy.flac"
"./02-Both Sides Now.flac"
"./03-Solitary Man.flac"
"./04-Holly Holy.flac"
"./05-Cherry Cherry.flac"
"./06-Kentucky Woman.flac"
"./07-Sweet Caroline.flac"
"./08-Thank the Lord for the Nightime.flac"
"./09-And the Singer Sings His Song.flac"
"./10-Brother Loves Traveling Salvation Show.flac"
I'm sure I'm overlooking something incredibly basic and obvious, but for the life of me I can't think of what!
If it makes a difference, this is under Ubuntu 18.04.1
find sort printf
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I need to pass a list of sorted, quoted FLAC file names to SoX for concatenation but am having trouble getting sort to work the way I expect it to.
If I use:
find . -maxdepth 1 -type f -iname "*.flac" | sort
I get exactly what I expect:
./01-Lordy.flac
./02-Both Sides Now.flac
./03-Solitary Man.flac
./04-Holly Holy.flac
./05-Cherry Cherry.flac
./06-Kentucky Woman.flac
./07-Sweet Caroline.flac
./08-Thank the Lord for the Nightime.flac
./09-And the Singer Sings His Song.flac
./10-Brother Loves Traveling Salvation Show.flac
However, I can't really use that for what I'm doing since I need a quoted list with no newlines. I know -printf can do that for me, but when I try:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" " | sort
I wind up with a list of file names that are quoted and separated by a single space (good!) but they aren't sorted (bad!). Or at least they aren't sorted the way I expect them to be:
"./08-Thank the Lord for the Nightime.flac" "./03-Solitary Man.flac" "./09-And the Singer Sings His Song.flac" "./05-Cherry Cherry.flac" "./06-Kentucky Woman.flac" "./10-Brother Loves Traveling Salvation Show.flac" "./07-Sweet Caroline.flac" "./02-Both Sides Now.flac" "./01-Lordy.flac" "./04-Holly Holy.flac"
Maybe even weirder, if I just for the sake of testing use the same code but add a newline:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" "\n | sort
The sort works even if the output is back to not being what I need:
"./01-Lordy.flac"
"./02-Both Sides Now.flac"
"./03-Solitary Man.flac"
"./04-Holly Holy.flac"
"./05-Cherry Cherry.flac"
"./06-Kentucky Woman.flac"
"./07-Sweet Caroline.flac"
"./08-Thank the Lord for the Nightime.flac"
"./09-And the Singer Sings His Song.flac"
"./10-Brother Loves Traveling Salvation Show.flac"
I'm sure I'm overlooking something incredibly basic and obvious, but for the life of me I can't think of what!
If it makes a difference, this is under Ubuntu 18.04.1
find sort printf
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you have to usefindhere, for the recursion? Or are all the desired files in the same directory? (I ask, given the-maxdepth 1and the sample output indicating the same directory)
– Jeff Schaller
2 mins ago
add a comment |
I need to pass a list of sorted, quoted FLAC file names to SoX for concatenation but am having trouble getting sort to work the way I expect it to.
If I use:
find . -maxdepth 1 -type f -iname "*.flac" | sort
I get exactly what I expect:
./01-Lordy.flac
./02-Both Sides Now.flac
./03-Solitary Man.flac
./04-Holly Holy.flac
./05-Cherry Cherry.flac
./06-Kentucky Woman.flac
./07-Sweet Caroline.flac
./08-Thank the Lord for the Nightime.flac
./09-And the Singer Sings His Song.flac
./10-Brother Loves Traveling Salvation Show.flac
However, I can't really use that for what I'm doing since I need a quoted list with no newlines. I know -printf can do that for me, but when I try:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" " | sort
I wind up with a list of file names that are quoted and separated by a single space (good!) but they aren't sorted (bad!). Or at least they aren't sorted the way I expect them to be:
"./08-Thank the Lord for the Nightime.flac" "./03-Solitary Man.flac" "./09-And the Singer Sings His Song.flac" "./05-Cherry Cherry.flac" "./06-Kentucky Woman.flac" "./10-Brother Loves Traveling Salvation Show.flac" "./07-Sweet Caroline.flac" "./02-Both Sides Now.flac" "./01-Lordy.flac" "./04-Holly Holy.flac"
Maybe even weirder, if I just for the sake of testing use the same code but add a newline:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" "\n | sort
The sort works even if the output is back to not being what I need:
"./01-Lordy.flac"
"./02-Both Sides Now.flac"
"./03-Solitary Man.flac"
"./04-Holly Holy.flac"
"./05-Cherry Cherry.flac"
"./06-Kentucky Woman.flac"
"./07-Sweet Caroline.flac"
"./08-Thank the Lord for the Nightime.flac"
"./09-And the Singer Sings His Song.flac"
"./10-Brother Loves Traveling Salvation Show.flac"
I'm sure I'm overlooking something incredibly basic and obvious, but for the life of me I can't think of what!
If it makes a difference, this is under Ubuntu 18.04.1
find sort printf
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need to pass a list of sorted, quoted FLAC file names to SoX for concatenation but am having trouble getting sort to work the way I expect it to.
If I use:
find . -maxdepth 1 -type f -iname "*.flac" | sort
I get exactly what I expect:
./01-Lordy.flac
./02-Both Sides Now.flac
./03-Solitary Man.flac
./04-Holly Holy.flac
./05-Cherry Cherry.flac
./06-Kentucky Woman.flac
./07-Sweet Caroline.flac
./08-Thank the Lord for the Nightime.flac
./09-And the Singer Sings His Song.flac
./10-Brother Loves Traveling Salvation Show.flac
However, I can't really use that for what I'm doing since I need a quoted list with no newlines. I know -printf can do that for me, but when I try:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" " | sort
I wind up with a list of file names that are quoted and separated by a single space (good!) but they aren't sorted (bad!). Or at least they aren't sorted the way I expect them to be:
"./08-Thank the Lord for the Nightime.flac" "./03-Solitary Man.flac" "./09-And the Singer Sings His Song.flac" "./05-Cherry Cherry.flac" "./06-Kentucky Woman.flac" "./10-Brother Loves Traveling Salvation Show.flac" "./07-Sweet Caroline.flac" "./02-Both Sides Now.flac" "./01-Lordy.flac" "./04-Holly Holy.flac"
Maybe even weirder, if I just for the sake of testing use the same code but add a newline:
find . -maxdepth 1 -type f -iname "*.FlAc" -printf ""%p" "\n | sort
The sort works even if the output is back to not being what I need:
"./01-Lordy.flac"
"./02-Both Sides Now.flac"
"./03-Solitary Man.flac"
"./04-Holly Holy.flac"
"./05-Cherry Cherry.flac"
"./06-Kentucky Woman.flac"
"./07-Sweet Caroline.flac"
"./08-Thank the Lord for the Nightime.flac"
"./09-And the Singer Sings His Song.flac"
"./10-Brother Loves Traveling Salvation Show.flac"
I'm sure I'm overlooking something incredibly basic and obvious, but for the life of me I can't think of what!
If it makes a difference, this is under Ubuntu 18.04.1
find sort printf
find sort printf
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 3 mins ago
Jeff Schaller
39.5k1054126
39.5k1054126
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 11 mins ago
atrocityatrocity
11
11
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
atrocity is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Do you have to usefindhere, for the recursion? Or are all the desired files in the same directory? (I ask, given the-maxdepth 1and the sample output indicating the same directory)
– Jeff Schaller
2 mins ago
add a comment |
Do you have to usefindhere, for the recursion? Or are all the desired files in the same directory? (I ask, given the-maxdepth 1and the sample output indicating the same directory)
– Jeff Schaller
2 mins ago
Do you have to use
find here, for the recursion? Or are all the desired files in the same directory? (I ask, given the -maxdepth 1 and the sample output indicating the same directory)– Jeff Schaller
2 mins ago
Do you have to use
find here, for the recursion? Or are all the desired files in the same directory? (I ask, given the -maxdepth 1 and the sample output indicating the same directory)– Jeff Schaller
2 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
atrocity is a new contributor. Be nice, and check out our Code of Conduct.
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%2funix.stackexchange.com%2fquestions%2f495547%2ffind-printf-sort-conflict%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
atrocity is a new contributor. Be nice, and check out our Code of Conduct.
atrocity is a new contributor. Be nice, and check out our Code of Conduct.
atrocity is a new contributor. Be nice, and check out our Code of Conduct.
atrocity is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f495547%2ffind-printf-sort-conflict%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
Do you have to use
findhere, for the recursion? Or are all the desired files in the same directory? (I ask, given the-maxdepth 1and the sample output indicating the same directory)– Jeff Schaller
2 mins ago