This sample script should obtain a list of files in my home directory:
#!/bin/bash
# Manipulate files and copy to my home directory
#
for FILE in $HOME/.bash*
do
cp $FILE ${HOME}/public_html
chmod a+r ${HOME}/public_html/${FILE}
done
Unfortunately it only produces an error:
-bash-3.2$ ./fileloop.sh
chmod: can't access /students/kporte01/public_html//students/kporte01/.bash_history
chmod: can't access /students/kporte01/public_html//students/kporte01/.bash_profile
chmod: can't access /students/kporte01/public_html//students/kporte01/.bashrc
Running the script in debug mode, the result is:
-bash-3.2$ ./fileloop.sh
+ for FILE in '$HOME/.bash*'
+ cp /students/kporte01/.bash_history /students/kporte01/public_html
+ chmod a+r /students/kporte01/public_html//students/kporte01/.bash_history
chmod: can't access /students/kporte01/public_html//students/kporte01/.bash_history
+ for FILE in '$HOME/.bash*'
+ cp /students/kporte01/.bash_profile /students/kporte01/public_html
+ chmod a+r /students/kporte01/public_html//students/kporte01/.bash_profile
chmod: can't access /students/kporte01/public_html//students/kporte01/.bash_profile
+ for FILE in '$HOME/.bash*'
+ cp /students/kporte01/.bashrc /students/kporte01/public_html
+ chmod a+r /students/kporte01/public_html//students/kporte01/.bashrc
chmod: can't access /students/kporte01/public_html//students/kporte01/.bashrc
Hmmm... what did I miss?