Search code examples
linuxbashshellls

shell script to find only the list of all folders created in last n minutes


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


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 '^(\.|\.\.)$'