Sample Header Ad - 728x90

Bash script selecting folder

0 votes
1 answer
1817 views
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"; do test -n "$d" && break; echo ">>> Wrong Folder Selection!!! Try Again"; done It fails also. I hope this make sense. Thank you
Asked by KpDean (3 rep)
Sep 1, 2020, 07:25 AM
Last activity: Sep 1, 2020, 04:39 PM