I'm afraid that stubbornly repeating your question as well as that code snippet, ignoring any of the proposals given in this thread, won't take you anywhere.
Why don't you take a step back and start over from the beginning, specify your needs - in detail! - , your data (structures), and the desired outcome, describe what you have (obviously that for loop) and its results, what and where it does NOT satisfy your needs, show the results of the proposals given and their shortcomings, and eventually errors occurring? That MIGHT put us in a position to help you.
i tested all above i am not ignoring the posts above, i thanked for all the posts as i am tried it all, but none worked the way, i want, sort it by latest created dirs by the loop script
that loop i have now only show all dirs in /home/test/, those are NOT sorted by created date in any way, probably just by name...
simply i need in that loop sort dirs by created date/time ...
In what way did they not work? "Does not work" is manifestly unhelpful. They might be one minor correction away from working for all we know - rejecting them out of hand without even bothering to explain why is a huge waste of our time and effort.
Show what you tried, word for word, letter for letter, keystroke for keystroke.
Show what happened. Do not paraphrase. Show the real result.
Show how the result is different from what you wanted.
Either work with the people trying to help you, or I will close this thread.
i tested all above i am not ignoring the posts above, i thanked for all the posts as i am tried it all, but none worked the way, i want, sort it by latest created dirs by the loop script
that loop i have now only show all dirs in /home/test/, those are NOT sorted by created date in any way, probably just by name...
simply i need in that loop sort dirs by created date/time ...
Yes, you are ignoring everything that has been said.
First, you can't get output file directory creation order unless the filesystem you are using stores that information. You haven't told us what operating system and filesystem type you're using; so our first guess is that what you want CANNOT be done on your system.
Second you never said anything about sorting in reverse order and until post #9 you never gave any indication that sorting by creation date was not sorting by increasing creation date (instead of decreasing creation date).
Third, if you are using a filesystem type that keeps creation date data, I told you exactly how to find out how print directories in increasing creation date order on BSD systems in post #6 and told you where to look for the option to use on your system. Did you bother looking at the ls man page on your system to see if your system provides an option to sort by file creation time? If so, what filesystem types on your system provide file creation time data? Is the filesystem where the directories you want to process one of those filesystem types? If the answer to any of these questions is no, there is nothing we can do to help you unless you move your files to a filesystem type that keeps track of file creation dates and you mount that filesystem on a system with an ls utility that provides a way to sort its output based on file creation dates.
Fourth, the code that you keep showing us is code that prints directories in increasing alphanumeric order. None of the examples we have suggested print directories in alphabetic order unless the file status change time or file creation time happens to be the same order as alphabetic order. To get output from ls in reverse sorted order add the -r option to any of the ls commands we suggested.
This User Gave Thanks to Don Cragun For This Post:
i just said none worked THE WAY i wanted, i did not said "it does not work"
so all being said, all post above this just do not reproduce following output -> SORT BY DATE CREATION what more to say?
Many of them clearly and obviously do. I see literally no indication you've actually tried them. Which isn't to say you haven't, but if you have and didn't post what you did and its results, you've wasted your own time.
Complaining is useless. If you show what you try and exactly the results you get, maybe we can figure out why. (Do those folders actually have ctimes like you think, or are they just NAMED those dates?)
As is, we have nothing to work from, and neither do you. Last chance before thread closure.
Hi everyone
I need some help
I want to create an script which does some processing
it takes the two arguments 201901010000 and 201901020200 - so YYYMMDDHHMM
I want to split processing into hours from start until end,
I dont get why this works but when I add to a future variable... (1 Reply)
i read here that linux provides no way to determine when a directory was created.
https://www.unix.com/shell-programming-and-scripting/157874-creation-date-directory.htmlI have a directory /home/andy/scripts that had a README file in it.
That file says
I put the script in that directory and... (3 Replies)
Hi everyone :-)
I ran into a small issue. I would like to copy some files in the precise order they were created.
So the oldest files should be copied first and the newest ones last.
I tried cp -r $(ls -1t) ./destination but the files are still not sorted properly. I was thinking, that... (11 Replies)
Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word
#!/bin/bash
for filename in /home/test/*
do
if ; then
echo $filename;
fithx! (4 Replies)
I have a bash that downloads a list and if that list has data in it then a new main directory is created (with the date) with several subdirectories (example1, example2, example3). My question is in that list there are portion of specific file types (.vcf.gz) - identifier towards the end that have... (0 Replies)
Hi
I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job.
Please help (2 Replies)
Hi All,
Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates.
While visiting couple of posts, i could see we can... (3 Replies)
Hi Expert,
Need your scripting and finding data so that it help me to find the culprit of this memory usage error.
Data provided here is a sample.
Process Snapshot directory: /var/spool/processes-snapshot
webdev9o9% pwd
/var/spool/processes-snapshot
webdev9o9% ls -lrct
-rw-r--r-- ... (3 Replies)
hello
i have a requirement where i have a direcotry in which i get files in the format
STOCKS.20080114.dat
STOCKS.20080115.dat
STOCKS.20080117.dat
STOCKS.20080118.dat
i need to loop through the directory and sort by create date descending order and i need to process the first file.
... (1 Reply)