![]() |
|
|
|
|
|||||||
| 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 |
| command to list a only sub-directories | mail2sant | UNIX for Dummies Questions & Answers | 1 | 05-09-2008 07:11 AM |
| Want to Get List of All directories | niceboykunal123 | Shell Programming and Scripting | 6 | 05-06-2008 11:58 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 |
| list only directories in commandline. | jhmr7 | UNIX for Dummies Questions & Answers | 8 | 03-18-2005 10:30 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
how to list directories only
I would like to know how to list directories only without a / at the end. I would like to only see them in my current dir.
for example ls - d */ gives dir1/ dir2/ dir3/ dir4/ but is there a way to get only dir1 dir2 dir3 i need it to use them as inputs in a foreach loop where i want to perform an action in my sub directories, but the / at the end is giving me problems thanks |
| Forum Sponsor | ||
|
|
|
|||
|
echo `ls -d */ | cut -f 1 -d /` that gets rid of the "/" but then the output is as follows:
e.g. echo `ls -d */ | cut -f 1 -d /` gives dir1 dir2 dir3 dir4 dir5 dir6 etc if you use it without the echo and it works fine ls -d */ | cut -f 1 -d / dir1 dir2 dir3 ... Peace Last edited by Ecclesiastes; 04-26-2006 at 01:32 AM. |
|
|||
|
Quote:
probably you might have set an alias for ls as ls='ls -F' check in your .profile else use the full path /bin/ls |
| Thread Tools | |
| Display Modes | |
|
|