Question: In my current working directory how can I find the last modified directory ?
Way1:
$ ls -lrt | awk '/^d/ { f=$NF }; END{ print f }'
Way2:
$ ls -d --sort=time */ | head -n 1
Relates post:
- Find the latest file in a directory in UNIX
Any better way to find this? please suggest; really appreciated. Thanks.
2 comments:
ls -td * | head -1 is slightly shorter than your second option...
@Ontureno: Thanks.
Post a Comment