Find the answer to your Linux question:
Results 1 to 3 of 3
Is there a method in which I can list all the directories under root to a text file ? I've tried ls -R but cannot tie this in the -d ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2003
    Posts
    15

    ls command --> capturing data


    Is there a method in which I can list all the directories under root to a text file ?
    I've tried ls -R but cannot tie this in the -d to show me just the directories...

    thanks
    mike

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    -d doesn't make ls only list directories. It makes ls list directory names found on the command line instead of recursing into them.
    I'm not sure exactly what you want to do, but I'm guessing that what you want is this:
    [code]find / -type d -maxdepth 2 >file{/code]

  3. #3
    Just Joined!
    Join Date
    May 2003
    Posts
    15

    Thank you...

    Once again LinuxForums to the rescue.....
    feel slightly piss*ff though - I would never have known that.......

    thanks for your help....

Posting Permissions

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