The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Want to Get List of All directories niceboykunal123 Shell Programming and Scripting 7 06-10-2009 03:05 AM
help with script to list directories chassis Shell Programming and Scripting 2 09-13-2006 02:17 PM
how to list directories only yodadbl07 UNIX for Dummies Questions & Answers 3 04-26-2006 05:48 AM
How to list only directories? videsh77 UNIX for Dummies Questions & Answers 4 01-09-2006 10:10 AM
List directories malaymaru UNIX for Dummies Questions & Answers 3 09-25-2005 10:54 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2005
jhmr7 jhmr7 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 11
list only directories in commandline.

I want to list only directories in the command line using ls command. Can anyone please help me.
  #2 (permalink)  
Old 03-17-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
ls -l | grep ^d
  #3 (permalink)  
Old 03-17-2005
jhmr7 jhmr7 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 11
Thanks. Please find the display below.

/home/gsk/prod> ls -l | grep ^d

drwxrwxr-x 2 gsk stage 96 Mar 17 14:01 0010
drwxrwxr-x 2 gsk stage 96 Mar 17 14:01 0011
drwxrwxr-x 2 gsk stage 96 Mar 17 14:01 0014

But i need to extract only the last column i.e. only the folder names. Please let me know what i need to do. I used cut utility but i can't able to locate the column. Is there any utility which will extract the last column of the display.

TIA.
  #4 (permalink)  
Old 03-17-2005
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Quote:
Originally Posted by jhmr7
But i need to extract only the last column i.e. only the folder names. Please let me know what i need to do. I used cut utility but i can't able to locate the column. Is there any utility which will extract the last column of the display.

Code:
ls -l | grep ^d | awk '{print $9}'

  #5 (permalink)  
Old 03-17-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,240
or

Code:
ls -l | awk '/^d/ {print $9}'

  #6 (permalink)  
Old 03-17-2005
jhmr7 jhmr7 is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 11
Thanks a lot guys. Your help is much appreciated.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0