I need to get the latest directory name in a folder which start with nlb.
#!/bin/sh
cd /home/ashot/checkout
dirname=`ls -t nlb* | head -1`
echo $dirname
When the folder contains many folders with name starting nlb, this script works fine, but when there is only one folder with name starting nlb, this script prints the latest file name inside that folder. How to change it to get the latest directory name?