The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display number of subdirectories jjamd64 Shell Programming and Scripting 2 12-13-2007 08:06 AM
Backup Directories and SubDirectories with log using DOS osramos Windows & DOS: Issues & Discussions 1 11-14-2007 02:10 PM
Compare/Diff between directories and subdirectories? andylee80 UNIX for Dummies Questions & Answers 5 07-12-2007 06:45 AM
Permissions for Directories and Subdirectories clancymf UNIX for Dummies Questions & Answers 1 08-07-2006 03:40 PM
How to Remove Ctrl M characters in files from directories and its subdirectories skdp Shell Programming and Scripting 7 07-29-2006 08:53 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-24-2007
HAA HAA is offline
Registered User
 

Join Date: Feb 2006
Posts: 24
Stumble this Post!
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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-24-2007
HAA HAA is offline
Registered User
 

Join Date: Feb 2006
Posts: 24
Stumble this Post!
Display subfolders from given folder

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
Reply With Quote
  #3 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,540
Stumble this Post!
don't understand. What have you tried? doesn't the normal "ls -ltr" command work for you?, or maybe i misinterpret what you want.
Reply With Quote
  #4 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Code:
ls -lR | awk ' NF < 3 || /^d/ && sub($1" +"$2" +"$3" +"$4" +"$5,"") '
Reply With Quote
  #5 (permalink)  
Old 04-24-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,323
Stumble this Post!
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:
Code:
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.
Reply With Quote
  #6 (permalink)  
Old 04-25-2007
HAA HAA is offline
Registered User
 

Join Date: Feb 2006
Posts: 24
Stumble this Post!
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
Reply With Quote
  #7 (permalink)  
Old 04-25-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Quote:
Originally Posted by HAA
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
Change sub function in above code to get what you need
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0