The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 02:05 AM
list only directories in commandline. jhmr7 UNIX for Dummies Questions & Answers 9 06-10-2009 02:01 AM
command to list a only sub-directories mail2sant UNIX for Dummies Questions & Answers 1 05-09-2008 10:11 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 09:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2006
yodadbl07 yodadbl07 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 11
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
  #2 (permalink)  
Old 04-26-2006
Ecclesiastes Ecclesiastes is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 8
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 04:32 AM..
  #3 (permalink)  
Old 04-26-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Quote:
Originally Posted by yodadbl07
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

probably you might have set an alias for ls as ls='ls -F'
check in your .profile

else use the full path /bin/ls
  #4 (permalink)  
Old 04-26-2006
yodadbl07 yodadbl07 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 11
Ecclesiastes thanks bro
Closed Thread

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 08:51 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