I am trying to list all the directory latest modified folder first using select, but I am stuck.
Let's say I have:
Folder1
ThisIsAnotherDir
Directory
New Directory
This IS not_Same Directory
When I run following command:
ls -t -d */
I get the desired output.
But when I use select:
options=$(ls -t -d */)
select d in $options; do test -n "$d" && break; echo ">>> Wrong Folder Selection!!! Try Again"; done
It lists the folder modified first, but, if I modified New Directory last and run this, it outputs:
1)New
2)Directory
3)Folder1
4)ThisIsAnotherDir
5)Directory
6)This
7)IS
8)not_Same
9)Directory
I also tried:
select d in "$options[0]"; do test -n "$d" && break; echo ">>> Wrong Folder Selection!!! Try Again"; done
It fails also.
I hope this make sense. Thank you