How to sort files in unix

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















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










share|improve this question
























  • Stack Exchange sites are not code writing services.

    – Rob
    Jan 31 at 15:07















0















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










share|improve this question
























  • Stack Exchange sites are not code writing services.

    – Rob
    Jan 31 at 15:07













0












0








0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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










1 Answer
1






active

oldest

votes


















2














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?






share|improve this answer


















  • 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











  • Stack Exchange sites are not code writing services.

    – Rob
    Jan 31 at 15:08










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
);



);













draft saved

draft discarded


















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









2














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?






share|improve this answer


















  • 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











  • Stack Exchange sites are not code writing services.

    – Rob
    Jan 31 at 15:08















2














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?






share|improve this answer


















  • 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











  • Stack Exchange sites are not code writing services.

    – Rob
    Jan 31 at 15:08













2












2








2







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?






share|improve this answer













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?







share|improve this answer












share|improve this answer



share|improve this answer










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 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












  • 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











  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?