![]() |
|
|
|
|
|||||||
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Want to Get List of All directories | niceboykunal123 | Shell Programming and Scripting | 6 | 05-06-2008 11:58 AM |
| help with script to list directories | chassis | Shell Programming and Scripting | 2 | 09-13-2006 10:17 AM |
| how to list directories only | yodadbl07 | UNIX for Dummies Questions & Answers | 3 | 04-26-2006 01:48 AM |
| How to list only directories? | videsh77 | UNIX for Dummies Questions & Answers | 4 | 01-09-2006 06:10 AM |
| List directories | malaymaru | UNIX for Dummies Questions & Answers | 3 | 09-25-2005 06:54 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
list only directories in commandline.
I want to list only directories in the command line using ls command. Can anyone please help me.
|
| Forum Sponsor | ||
|
|
|
|||
|
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. |
|
|||
|
Quote:
Code:
ls -l | grep ^d | awk '{print $9}'
|
|
|||
|
How about as an alias in .cshrc ?
I've put this line as an alias in .cshrc:
alias dirlist ls -l | awk '/^d/ {print $9}' but I get this: netmin@kenny:/home/netmin-->> dirlist drwx------ 5 netmin netmin 512 Mar 13 04:26 Maildir drwxr-xr-x 2 netmin netmin 512 Mar 15 18:30 bin drwxr-xr-x 2 netmin netmin 512 Mar 15 18:00 cdrom drwxr-xr-x 2 netmin netmin 512 Mar 15 07:37 conf drwxr-xr-x 2 netmin netmin 512 Mar 12 09:50 doc drwx------ 2 netmin netmin 512 Mar 13 12:43 mail drwxr-xr-x 4 netmin netmin 512 Mar 13 20:16 mailconf What do I need to do to get the {print $9} to take ? Thanks in advance. Jolok |