# Basic script?

**URL:** <https://community.unix.com/t/basic-script/176472>\
**Category:** Shell Programming and Scripting\
**Created:** [October 10, 2007, 1:42pm UTC](https://community.unix.com/t/basic-script/176472 "2007-10-10T13:42:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjbaumann](https://community.unix.com/letter_avatar/kjbaumann/32/6_449c533f586939b6e5f246632a46421f.png) [@kjbaumann](https://community.unix.com/u/kjbaumann)\
**Post date:** [October 10, 2007, 1:42pm UTC](https://community.unix.com/t/basic-script/176472/1 "2007-10-10T13:42:55Z")

</div>

All,

I have a list of over 400 users that need certain directories created. These will be created in /users/$username on a system and I need a directory called chess under these directories that I create.

Instead of me manually adding each one (mkdir /users/user1, mkdir /users/user1/chess) then changing the ownership (chown -R user1:group) I would love to have a script ask me for a username and have it to the work.

I'm not too familiar with scripts asking for input so any help would be greatly appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![synak](https://community.unix.com/letter_avatar/synak/32/6_449c533f586939b6e5f246632a46421f.png) [@synak](https://community.unix.com/u/synak)\
**Post date:** [October 10, 2007, 3:22pm UTC](https://community.unix.com/t/basic-script/176472/2 "2007-10-10T15:22:41Z")

</div>

#!/bin/bash  
if [$# -eq "0"]  
then  
# this prints the usage if no arguments are received.  
echo "usage: `basename $0` \<user\>"  
exit  
fi

# check if username provided to script is a valid user  
if [`grep -i ^$1: /etc/passwd`]  
then  
mkdir /users/$1  
mkdir /users/$1/chess  
chown -R $1:users /users/$1  
else  
echo user $1 not found  
fi
