Find the answer to your Linux question:
Results 1 to 2 of 2
A bash script or command required to list all the directories under a given path. I tried this script(command perhaps) for the same: #!/bin/sh ls -lR | grep ^d Though ...
  1. #1
    Just Joined!
    Join Date
    Jun 2007
    Posts
    3

    bash script to list all directories

    A bash script or command required to list all the directories under a given path.

    I tried this script(command perhaps) for the same:

    #!/bin/sh
    ls -lR | grep ^d

    Though this lists all the dirs, we can really use this to a great extent

  2. #2
    Just Joined!
    Join Date
    Jun 2007
    Posts
    3

    command to list all directories

    Here is a simpler version and efficient version:

    #!/bin/sh

    Dirlist=$(find . -type d)
    for direc in $Dirlist ; do
    ls $direc
    done

    This bash script can be used to recursively list and use directories.
    Traverse the directories using bash script search result was to big to find any solution, so thought to delve into Man and got this...

    Its so easy if known how to read Man pages...

    Srinivas

Posting Permissions

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