Display only subdirectories from given directories

Hi Genius,

I would like to display all the subdirectories only with timestamp.

For exmple:

Given Directory : orabkup

/orabkup
total 11365112
drwxr-xr-x 9 oracle oradba 256 Jan 03 16:01 db1

/orabkup/db1:
total 0
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 ddl
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupd_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupc_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupb_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupa_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backup_ro
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backup

I would say thanks in advance whoever help me on above.

Regards,
HAA

Hi Genius,

I would like to display all the subdirectories only with timestamp.

For exmple:

Given Directory : orabkup

/orabkup
total 11365112
drwxr-xr-x 9 oracle oradba 256 Jan 03 16:01 db1

/orabkup/db1:
total 0
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 ddl
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupd_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupc_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupb_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backupa_rw
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backup_ro
drwxr-xr-x 2 oracle oradba 256 Jan 03 16:01 backup

I would say thanks in advance whoever help me on above.

Regards,
HAA

don't understand. What have you tried? doesn't the normal "ls -ltr" command work for you?, or maybe i misinterpret what you want.

ls -lR | awk ' NF < 3 || /^d/ && sub($1" +"$2" +"$3" +"$4" +"$5,"") '

First suggestion: I'm not sure if we have any users named Genius. And if we do, unless you are addressing the post to them, don't start with 'Hi Genius'.

Now for your question, you can use the find command to do this. It will, by default, recurse into any subdirectories that are present in your given directory. The find command goes like this:

find <dir to search in> -type d # this restricts the search to directories only

# example:
find /orabackup -type d -exec ls -ld {} \;

For more details on find, as always, lookup the man page.

Once again Excellent reply Anbu.

Many thanks to u,

in same manner i want to display the size of the directory,permissions along with timestamp.

Regards,
HAA :slight_smile:

Change sub function in above code to get what you need

Do not create multiple threads for the same query. Read the rules please. Threads merged.

ls -lR | awk '/^d/ { printf("%s %s %s %s %s %s\n",$1,$5,$6,$7,$8,$9) } '