Results 1 to 3 of 3

Thread: how to display all folders (bash shell script)

  1. #1

    how to display all folders (bash shell script)

    hi,

    Code:
    #!/bin/bash
    for var in `find /home/ -type d | \
    sed -e "s/\/home\///"`; do
    echo $var
    done
    in this code to display
    Code:
    user1/public_html/XXXX/XXXX
    user1/XXX/XXXX/XXXX/XXXX/XXXX
    user2/XXXXXX/XXXX/XXXX/XXXX/XXXX
    user2/XXXX/XXXX/XXXX/XXXX/XXXX
    user2/XXX/XXXX/XXXX/XXXX
    user3/XX/XXXX/XXXX/XXXX/XXXX
    what code to display (use for loop)
    Code:
    user1
    user2
    user3

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    So you only want to pick out the <USER> part of your find request ?
    Code:
    for var in `find /home/ -type d | awk -F / '{print $3}' |uniq`; do echo $var done
    Or you just want to show which <USER> there are located in /home ?
    Code:
    for var in `ls /home/*`; do echo $var done
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  3. #3
    tnx redhead for reply

    this code will be need
    Code:
    #!/bin/bash
    for var in `find /home/ -type d -maxdepth 1 | \
    sed -e "s/\/home\///"`; do
    echo $var
    done

Similar Threads

  1. SSH and bash script
    By vwgtiturbo in forum Programming
    Replies: 7
    Last Post: 12-25-2008, 04:40 AM
  2. Bash script
    By linuxuser in forum Programming
    Replies: 1
    Last Post: 09-01-2005, 03:21 PM
  3. List of fixes included in Windows XP SP2
    By regix in forum Windows - General Topics
    Replies: 6
    Last Post: 01-03-2005, 10:44 PM
  4. Shell Script to modify apachectl
    By gaxprels in forum Programming
    Replies: 6
    Last Post: 07-23-2002, 07:18 PM
  5. Help with bash script
    By tolstoy in forum Programming
    Replies: 5
    Last Post: 05-21-2002, 11:17 AM

Bookmarks

Posting Permissions

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