Question

I want to list all folders inside a folder, created in last n minutes. It should not include the sub folders inside a folder. I tried the following which did not worked

ls   -d  * | find -cmin -60

Please suggest some way

Thanks in advance

Was it helpful?

Solution

e.g.:

find . -maxdepth 1 -type d -cmin -60 -print | egrep -v '^(\.|\.\.)$' | sed 's/..//'

will find all directories and don't go to sub-dirs, and exclude . and ..

EDIT: now will print instead of ./dir only dir

alternatively,

find . -maxdepth 1 -type d -cmin -60 -printf "%f\n" | egrep -v '^(\.|\.\.)$'

OTHER TIPS

It's easier to do

find . -type d -cmin -60 -print

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top