LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2006, 06:37 AM   #1
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Rep: Reputation: 38
command to show only dirs in current dir?


As above, really.

Is there an option for ls (or an equivalent) to let me list only the directories? I've had a look at man ls and can't find anything.

In MS-DOS it was DIR /AD.

All i can find on the intarweb is other people asking the same question.

Last edited by Lordandmaker; 01-06-2006 at 06:39 AM.
 
Old 01-06-2006, 06:53 AM   #2
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
I have this alias:

Code:
alias lsd="ls -la | grep ^d"
grep ^d means only display lines beginning with d
 
Old 01-06-2006, 07:08 AM   #3
carl0ski
Member
 
Registered: Sep 2004
Location: Melbourne, Victoria Australia
Distribution: Support those that support you :)
Posts: 872
Blog Entries: 12

Rep: Reputation: 30
Quote:
Originally Posted by Lordandmaker
As above, really.

Is there an option for ls (or an equivalent) to let me list only the directories? I've had a look at man ls and can't find anything.

In MS-DOS it was DIR /AD.

All i can find on the intarweb is other people asking the same question.
ls|grep '/'|grep -v '^$'>a.txt

or
ls|grep '/'|grep -v '^$'|cat

spose i should explain mine too
ls (list dah you can whatever you want here)
|grep '/' (i chose / since all directories hidden or not have a / at the end.)

|grep -v '^$' (only displays figures containing /


|cat last one can be cat ( display on screen or > output to text file)

Last edited by carl0ski; 01-06-2006 at 07:14 AM.
 
Old 01-06-2006, 07:11 AM   #4
Lordandmaker
Member
 
Registered: Sep 2005
Location: London, UK
Distribution: Debian
Posts: 258

Original Poster
Rep: Reputation: 38
Oooh yeh. forgot about aliases...

Cheers!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian: What is the command to show my current kernel version? charon79m Linux - General 4 01-18-2011 04:21 AM
su - and stay in current dir lord-fu Linux - Newbie 2 11-16-2005 08:08 AM
Bash script to process every file in current dir and sub dirs BuckRogers01 Linux - Software 3 09-06-2005 07:32 AM
command to show current display resolution ?? itsjustme Slackware 4 12-05-2003 01:59 PM
Cmd to rm dir thats has files and other dirs psyklops Linux - General 4 04-17-2002 08:12 PM


All times are GMT -5. The time now is 12:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration