Hi, I am trying to figure out how to have a folder created in multiple directories. For example /home is where we have over 1500 staff members directories, the staff members name is the name of directory under /home. I need to have a folder called "Desktop" created in every staff members directory. Any help is appreciated.
assuming the username does in fact match the /home directory name, try something like this:
cd /
ls -1 /home | \
while read directory ; do
if [[ -d /home/"$directory" ]]; then
mkdir /home/"$directory"/Desktop
chown "$directory" /home/"$directory"/Desktop
fi
done
Hi, I changed it ksh and I am still getting the error. This is what I have for the script..
#!/bin/ksh
cd /
ls -1 /home/staff/ | \
while read directory ; do
if [[ -d /home/staff/"$directory" ]]; then
mkdir /home/staff/"$directory"/Desktop
chown "$directory" /home/staff/"$directory"/Desktop
fi
done
Note: When I ran it on my OS X Server as a test it worked great.. But when I ran it on the actual FreeBSD machine it keeps giving this error.
[[: not found
[[: not found
[[: not found
[[: not found
[[: not found
Okay, So it would go something like this? I am sorry if I seem novice at this. I am learning a lot here at this forum and appreciate all your guys help..
#!/bin/ksh
cd /
echo $0
ls -1 /home/staff/ | \
while read directory ; do
if [[ -d /home/staff/"$directory" ]]; then
mkdir /home/staff/"$directory"/Desktop
chown "$directory" /home/staff/"$directory"/Desktop
fi
done
I am having a hard time installing ksh93 on my FreeBSD server. Im sure this will work if I ever get it installed (the make install is not working). Thank You for your help, I really do appreciate it.
Do you have bash? This script should run in bash without any modifications. Or, you can run it in sh. Change the first line to #!/bin/sh and change the following line: