Read directories sequential based on timestamp

Hi,
I have a directory structure like below
Directoryname create time
d1 12:00
d2 12:05
d3 12:08

I want to read the directories based on timestamp.That is oldest directory must be read first and kick off certain process.

Kindly let me know how can read these directories.

Thanks,
Chetan

Use ls -td to list the directories sorted by timestamp instead of name. Use the -r switch to reverse the sorting order (in case you need that).

I hope this helps.

bakunin

Thanks.
Apologies I did not give the complete information .

I require it to be in a for loop ,so that once the oldest directory is read the subsequent oldest directory is picked. The process after the directory name is picked is independant so it has to be a continuos process.

Thanks,
Chetan.C

Try

for i in $(ls -1Frt|grep '/$'|tr -d '/$')
do
#### processing with directory i ####
done
1 Like

What does it mean? Do you mean sub directories?
Also from continuous processing do you mean parallel?

Thanks!! its working Completing the script now...thanks again!:b:

---------- Post updated at 07:18 AM ---------- Previous update was at 07:17 AM ----------

Hi Anchal,

Actually for each directories i have ETL jobs that need to be triggered.
That is why i was looking for such option.

Thanks,
Chetan.C

---------- Post updated at 07:22 AM ---------- Previous update was at 07:18 AM ----------

Hi elixir_sinari,

Can you explain me what it is doing .Im doing a man for

-F

option of ls it says append indicator.So can i know what it means?

Thanks,
Chetan.C

Here's the man page section for the option:

 -F
      Puts a / (slash) after each file name if the file is a directory, an * (asterisk) if the file can be executed,
      an = (equal sign) if the file is a socket, a | (pipe) sign if the file is a FIFO, and an @ for a symbolic link.
      Symbolic links that are named as operands are not followed unless you have specified the -H or -L flag.

This is on AIX 5.3

try this

ls -lrtd * | grep "^d"