#!/bin/bash echo "file1=?" #転送元のファイルを指定 read file1 echo "file2=?" #転送先のファイルを指定 read file2 file3=`ls ${file1}` cd ${file1} #転送元のファイルの中に移動する for file4 in ${file3} do if [ -d ${file4} ] #まず、ディレクトリかを判定 then chmod 775 ${file4} #ディレクトリならパーミッションを775にする else case ${file4} #違う場合には、 in *.sh) chmod 775 ${file4} ;; #スクリプトならパーミッションを775に *) chmod 664 ${file4} ;; #その他ならパーミッションを664に esac fi cp -rp ${file4} ${file2} #パーミッション変更後、file4(転送元のファイル)をfile2(転送先のファイル)にコピー done