4 # Author:CaoJiangfeng 5 # Date: 2010-06-01 6 # 7 # The script is used to change file attributes 8 # Define a function 9
10 list_dir(){
11 # Traversal parameter $1 12 for file in $1/*
13 do
14 # If it is a directory then treat it ,after it's treated traverse it 15 if[-d $file]; then
16 echo "$file is directory"
17 chmod 755 $file
18 list_dir $file
19 elif [-f $file];
20 then
21 echo $file
22 #suffix=`echo -n $file |cut -f 2 -d '.'` 23 #suffix= echo -n "`echo $file |cut -f 3 -d '.'`" 24 suffix=`echo -n $file|awk -F.'{print $NF}'`
25 #echo "$suffix"
26 echo "$file is file "
27 chmod 644 $file
28 sud=sh # The varable is used to designate which suffix will be modified 29
30 if["$suffix"="$sud"];
31 then
32 chmod 744 $file
33 echo "$file changed"
34 fi
35 list_dir $file
36 fi
37 done
38 }
39
40
41
42 # If there is parameter to traverse the specified directory, 43 # otherwise the current directory traversal 44 if[$# -gt 0 ] ; 45 then
46 list_dir "$1"
47 else
48 list_dir "."
49 fi