How can I sort files without ls or find Announcing the arrival of Valued Associate #679: Cesar...

How to colour the US map with Yellow, Green, Red and Blue to minimize the number of states with the colour of Green

Estimated State payment too big --> money back; + 2018 Tax Reform

Can I throw a sword that doesn't have the Thrown property at someone?

When is phishing education going too far?

Limit for e and 1/e

What's the point in a preamp?

Stars Make Stars

Simulating Exploding Dice

Statistical model of ligand substitution

Replacing HDD with SSD; what about non-APFS/APFS?

Why is there no army of Iron-Mans in the MCU?

Who can trigger ship-wide alerts in Star Trek?

What do you call a plan that's an alternative plan in case your initial plan fails?

How do you clear the ApexPages.getMessages() collection in a test?

How should I respond to a player wanting to catch a sword between their hands?

Why is "Captain Marvel" translated as male in Portugal?

Cold is to Refrigerator as warm is to?

3 doors, three guards, one stone

How can players take actions together that are impossible otherwise?

Did the new image of black hole confirm the general theory of relativity?

Slither Like a Snake

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Geometric mean and geometric standard deviation

How to retrograde a note sequence in Finale?



How can I sort files without ls or find



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow to find image files by contentSort the output of find before piping to opensshFind files in directory with paired namesWhy are these values not appending correctly when appended to the pipeline?How can I list hidden directories, then directories, then hidden files and finally files with ls?Not able to find Output files for multiple input using for loopCompare files and rename if contents differAdd text to end of the filename but before extensionAlphabetize words within filenames using sort?How can I run a same command in mac terminal for multiple files in a folder?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need sorted list of files and directories in for-loop, must be files sorted before directories.I need this because im trying to copy and sequentially renaming files recursively and i tried with ls but its not worked recursively
like :



function traverse() {
counter=1

for file in `ls -rX $2`
do
if [ ! -d "${file}" ]; then
if [[ $file == $3 ]]; then
extension="${file##*.}"
filename="${file%.*}"
cp "${2}/${file}" "${2}/${4}${counter}.${extension}"
((++counter))
fi
elif [[ $1 == "-R" ]]; then
traverse "${1}" "${2}/${file}" "${3}" "${4}"
fi
done
}









share|improve this question







New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Sorted by what? Just file/directory separation?

    – Michael Homer
    47 mins ago




















0















I need sorted list of files and directories in for-loop, must be files sorted before directories.I need this because im trying to copy and sequentially renaming files recursively and i tried with ls but its not worked recursively
like :



function traverse() {
counter=1

for file in `ls -rX $2`
do
if [ ! -d "${file}" ]; then
if [[ $file == $3 ]]; then
extension="${file##*.}"
filename="${file%.*}"
cp "${2}/${file}" "${2}/${4}${counter}.${extension}"
((++counter))
fi
elif [[ $1 == "-R" ]]; then
traverse "${1}" "${2}/${file}" "${3}" "${4}"
fi
done
}









share|improve this question







New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Sorted by what? Just file/directory separation?

    – Michael Homer
    47 mins ago
















0












0








0








I need sorted list of files and directories in for-loop, must be files sorted before directories.I need this because im trying to copy and sequentially renaming files recursively and i tried with ls but its not worked recursively
like :



function traverse() {
counter=1

for file in `ls -rX $2`
do
if [ ! -d "${file}" ]; then
if [[ $file == $3 ]]; then
extension="${file##*.}"
filename="${file%.*}"
cp "${2}/${file}" "${2}/${4}${counter}.${extension}"
((++counter))
fi
elif [[ $1 == "-R" ]]; then
traverse "${1}" "${2}/${file}" "${3}" "${4}"
fi
done
}









share|improve this question







New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I need sorted list of files and directories in for-loop, must be files sorted before directories.I need this because im trying to copy and sequentially renaming files recursively and i tried with ls but its not worked recursively
like :



function traverse() {
counter=1

for file in `ls -rX $2`
do
if [ ! -d "${file}" ]; then
if [[ $file == $3 ]]; then
extension="${file##*.}"
filename="${file%.*}"
cp "${2}/${file}" "${2}/${4}${counter}.${extension}"
((++counter))
fi
elif [[ $1 == "-R" ]]; then
traverse "${1}" "${2}/${file}" "${3}" "${4}"
fi
done
}






bash shell-script






share|improve this question







New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 59 mins ago









zblashzblash

1




1




New contributor




zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






zblash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    Sorted by what? Just file/directory separation?

    – Michael Homer
    47 mins ago
















  • 1





    Sorted by what? Just file/directory separation?

    – Michael Homer
    47 mins ago










1




1





Sorted by what? Just file/directory separation?

– Michael Homer
47 mins ago







Sorted by what? Just file/directory separation?

– Michael Homer
47 mins ago












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


}
});






zblash is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512462%2fhow-can-i-sort-files-without-ls-or-find%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








zblash is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















zblash is a new contributor. Be nice, and check out our Code of Conduct.













zblash is a new contributor. Be nice, and check out our Code of Conduct.












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




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f512462%2fhow-can-i-sort-files-without-ls-or-find%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

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...