How to sort files in unix
Clash Royale CLAN TAG#URR8PPP
I have files in the following manner
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
I need to sort them into this order.
Desired output:
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
command-line filenames sort
add a comment |
I have files in the following manner
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
I need to sort them into this order.
Desired output:
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
command-line filenames sort
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07
add a comment |
I have files in the following manner
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
I need to sort them into this order.
Desired output:
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
command-line filenames sort
I have files in the following manner
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
I need to sort them into this order.
Desired output:
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
command-line filenames sort
command-line filenames sort
edited Jan 31 at 14:59
Jeff Schaller
41.8k1156133
41.8k1156133
asked Jan 31 at 13:54
Praveen KumarPraveen Kumar
394
394
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07
add a comment |
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07
add a comment |
1 Answer
1
active
oldest
votes
Using the 'en_US.UTF-8' locale caused the the '010' to appear before '01' when sorting. Forcing the C
locale for the sort works here:
$ LC_ALL=C ls -1
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
The C
locale is explained here: What does “LC_ALL=C” do?
1
May be worth noting that the*
glob would sort this way too and that reading the output fromls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).
– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
add a comment |
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
);
);
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%2f497936%2fhow-to-sort-files-in-unix%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
Using the 'en_US.UTF-8' locale caused the the '010' to appear before '01' when sorting. Forcing the C
locale for the sort works here:
$ LC_ALL=C ls -1
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
The C
locale is explained here: What does “LC_ALL=C” do?
1
May be worth noting that the*
glob would sort this way too and that reading the output fromls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).
– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
add a comment |
Using the 'en_US.UTF-8' locale caused the the '010' to appear before '01' when sorting. Forcing the C
locale for the sort works here:
$ LC_ALL=C ls -1
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
The C
locale is explained here: What does “LC_ALL=C” do?
1
May be worth noting that the*
glob would sort this way too and that reading the output fromls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).
– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
add a comment |
Using the 'en_US.UTF-8' locale caused the the '010' to appear before '01' when sorting. Forcing the C
locale for the sort works here:
$ LC_ALL=C ls -1
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
The C
locale is explained here: What does “LC_ALL=C” do?
Using the 'en_US.UTF-8' locale caused the the '010' to appear before '01' when sorting. Forcing the C
locale for the sort works here:
$ LC_ALL=C ls -1
ar01440_1775_17_vc00_00.png
ar01440_1775_17_vc00_01.png
ar01440_1775_17_vc00_010.png
ar01440_1775_17_vc00_011.png
ar01440_1775_17_vc00_012.png
ar01440_1775_17_vc00_013.png
ar01440_1775_17_vc00_014.png
ar01440_1775_17_vc00_015.png
ar01440_1775_17_vc00_016.png
ar01440_1775_17_vc00_017.png
ar01440_1775_17_vc00_018.png
ar01440_1775_17_vc00_019.png
ar01440_1775_17_vc00_02.png
ar01440_1775_17_vc00_03.png
ar01440_1775_17_vc00_04.png
ar01440_1775_17_vc00_05.png
ar01440_1775_17_vc00_06.png
ar01440_1775_17_vc00_07.png
ar01440_1775_17_vc00_08.png
ar01440_1775_17_vc00_09.png
The C
locale is explained here: What does “LC_ALL=C” do?
answered Jan 31 at 14:20
HaxielHaxiel
2,7851916
2,7851916
1
May be worth noting that the*
glob would sort this way too and that reading the output fromls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).
– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
add a comment |
1
May be worth noting that the*
glob would sort this way too and that reading the output fromls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).
– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
1
1
May be worth noting that the
*
glob would sort this way too and that reading the output from ls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).– Kusalananda
Jan 31 at 14:36
May be worth noting that the
*
glob would sort this way too and that reading the output from ls
is not really recommended (this is what I'm assuming that the user will do in the next step of whatever they're doing).– Kusalananda
Jan 31 at 14:36
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:08
add a comment |
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%2f497936%2fhow-to-sort-files-in-unix%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
Stack Exchange sites are not code writing services.
– Rob
Jan 31 at 15:07