Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, I am trying to find out the comand for listing the Directorys not the files. the ls command will list the files and there are many other manipulations of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Posts
    1

    Help with Syntax


    Hello, I am trying to find out the comand for listing the Directorys not the files.

    the ls command will list the files and there are many other manipulations of the ls command that list files, but what I'm looking for is a command that will list the directorys only?

    Is there such a beast?

    I've googled this thing to death.

    Thanks Kevin

  2. #2
    Linux Newbie jeickal's Avatar
    Join Date
    Jan 2005
    Location
    Switzerland
    Posts
    114
    How about:

    Code:
    ls -F | grep /

  3. #3
    Linux Newbie jeickal's Avatar
    Join Date
    Jan 2005
    Location
    Switzerland
    Posts
    114
    Actually, you don't need that "-F" (sorry, old Unix habit). that should work as well:

    Code:
    ls | grep /

  4. $spacer_open
    $spacer_close
  5. #4
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Code:
    find / -type d -print | xargs ls -ld
    will list all the directories on your system, subject to access permissions.

  6. #5
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Chicago (USA)
    Posts
    1,028
    Quote Originally Posted by jeickal
    Actually, you don't need that "-F" (sorry, old Unix habit). that should work as well:

    Code:
    ls | grep /
    That didn't work; you need the -F.

  7. #6
    Linux Newbie jeickal's Avatar
    Join Date
    Jan 2005
    Location
    Switzerland
    Posts
    114
    Quote Originally Posted by a thing
    That didn't work; you need the -F.
    I suppose it depends on the shell you use. I know you need the -F on the Korn shell. But on the Bash that I'm currently using, "ls" alone will display the "/" next to each directory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •