LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 05-25-2004, 04:49 PM   #1
d1s4st3r
Member
 
Registered: May 2004
Location: Italy
Posts: 70

Rep: Reputation: 16
How to see just dirs with ls?


Hi!
Once I learned all Linux basic commands and read the man page for "ls", I'm still wondering how can I list ONLY directories (hidden and not) within the ls default output form (columns).
If I want to see only the directories of a path, I use the following:
Code:
ls -la | grep "^d"
Code:
ls -laF | grep "/"
but I don't want directories listed (flag -l) in just one column, I want 'em distributed in moltiple columns without file permissions, owner, groups, etc...
How can I do this?
I realised there's no way for ls to simply show just directories and nothing else.
Could you give me an help, please?
Thanks a lot guys!
Bye
 
Old 05-25-2004, 05:12 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Here's something you can play with. It won't get the directories in columns though (unless you turn it into a script and do some magic).

find -maxdepth 1 -type d | cut -d / -f 2 | grep -v "^\." | sort

The cut command simply prunes the ./ at the beginning of every directory find returns

The grep command filters out the hidden directories

The sort command, well, sorts them alphabetically
 
Old 05-25-2004, 05:32 PM   #3
qizzer
LQ Newbie
 
Registered: Mar 2004
Location: USA
Distribution: Mandriva
Posts: 20
Blog Entries: 5

Rep: Reputation: 0
Here are a couple of options to play around with.
find . -type d -maxdepth 1
ls -a | grep /
ls -d */ gives unhidden directories but ls -da */ doesn't work as I expected.
good luck
 
Old 06-04-2004, 10:45 AM   #4
d1s4st3r
Member
 
Registered: May 2004
Location: Italy
Posts: 70

Original Poster
Rep: Reputation: 16
Solved!

ls -d .*"/" *"/"

Bye!
 
  


Reply



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
Symlink two dirs into one? neocookie Linux - General 7 05-27-2005 08:50 AM
add dirs to $PATH zchoyt Linux - General 4 09-13-2004 02:00 PM
ls, dirs first, files later TroelsSmit Linux - Newbie 4 05-31-2004 11:47 AM
removing dirs... chrismiceli Linux - General 5 10-25-2002 05:16 AM
hidden dirs? mighty Linux - General 3 11-03-2001 03:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:01 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
Open Source Consulting | Domain Registration