#!/bin/bash before=$1 #転送元のディレクトリをbeforeとする  after=$2 #転送先のディレクトリをafterとする cd $before #転送元のディレクトリに移動する cp *.{sh,html,txt} $after #「.」以下に「sh,html,txt」とつくものを転送先のディレクトリに移動させる cd $after #転送先のディレクトリに移動する echo "---before > after---" ls -l #ファイルの詳細を表示  ls *.sh | chmod 775 *.sh #「.」以下に「sh」とつくファイルのパーミッションを775に変更する ls *.{html,txt} | chmod 664 *.{html,txt} #「.」以下に「html,txt」とつくファイルのパーミッションを664に変更する echo "---change permission---" ls -l #ファイルの詳細を表示 cd $before #転送元のディレクトリに移動する ls -p | cp -r */ $after #ディレクトリを表す名称の末端に「/」をつけ、「/」のついたファイル(ディレクトリ)を転送する cd $after #転送先に移動する find . -type d -exec chmod -R 775 {} \; #転送先にあるディレクトリとそのディレクトリ以下にあるファイルのパーミッションを「775」に変更する。 find . -type f -exec chmod 664 {} \; #転送先にあるファイルのパーミッションを「664」に変更する。 find . -name "*.sh" -exec chmod 775 {} \; #転送先にある「.sh」のついたファイルのパーミッションを「775」に変更する。 echo "---change permission---" ls -l #ファイルの詳細を表示 now=`pwd` if [ $now = /home/$USER/public_html/report01 ] #もし、カレントディレクトリが「report01」なら then mkdir scripts #「scripts」ディレクトリを作成する。 mkdir results #「results」ディレクトリを作成する。 chmod 775 {scripts,results} #「scripts」「results」のパーミッションを適切な権限に変える mv *.sh scripts #「*.sh」を「scripts」へ移動 mv *.txt results #「*.txt」を「results」へ移動 cd scripts echo "---*.sh > scripts---" ls -l #移動出来ているか確認 cd .. cd results echo "---*.txt > results---" ls -l #移動出来ているか確認 fi