I am trying to find the oldest directory inside a directory. Currently my bash script is returning a directory but it isn't the oldest one.
Code -
DIR=$(ls -t1 | tail -n 1)
testDIR=$(find /Users/BigO/Downloads/shell -type d -maxdepth 1| sort | tail -n 1)
echo $DIR
echo $testDIR
outout
5_6_project_files_test
/Users/BigO/Downloads/shell/utdse19_ff-UI_3-4-19
DIR
prints out expected directory.
testDIR
wrong directory found, expected 5_6_project_files_test
Any idea on what im doing wrong? any help is appreciated. Thanks.