-
Notifications
You must be signed in to change notification settings - Fork 9
/
copy_modify_file.sh
executable file
·142 lines (108 loc) · 3.31 KB
/
copy_modify_file.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
SOURCE_PATH=.
DEST_PATH=/home/yuanda.yu/svn_debug/lite-ipc/trunk/retarded/app
h_c_to_hh_cc=0 #just use at vmware_share
hh_cc_to_h_c=1 #vmware_share(windows) to svn_debug(linux)
echo SOURCE_PATH = $SOURCE_PATH
echo DEST_PATH = $DEST_PATH
######将 .h .c .cpp 文件转换成 .hh .cc .cppp文件################################
if test $[h_c_to_hh_cc] -eq 1
then
c_file=`find $SOURCE_PATH -name *.c`
h_file=`find $SOURCE_PATH -name *.h`
cpp_file=`find $SOURCE_PATH -name *.cpp`
for file in $c_file # .c ---> .cc
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.cc
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
for file in $h_file # .h ---> .hh
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.hh
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
for file in $cpp_file #.cpp ---> .cppp
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.cppp
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
fi
#####################################################################
######将 .hh .c .cppp文件拷贝到指定目录下并转换成 .h .c .cpp文件####################
if test $[hh_cc_to_h_c] -eq 1
then
#拷贝
rm -rf $DEST_PATH/*
cp -rf $SOURCE_PATH/* $DEST_PATH/
#转换
cc_file=`find $DEST_PATH -name *.cc`
hh_file=`find $DEST_PATH -name *.hh`
cppp_file=`find $DEST_PATH -name *.cppp`
for file in $cc_file # .cc ---> .c
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.c
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
for file in $hh_file # .hh ---> .h
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.h
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
for file in $cppp_file # .cppp ---> .cpp
do
new_file=${file%.*} #%.* 表示从右边开始,删除第一个 . 号及右边的字符
new_file=${new_file}.cpp
#echo $new_file
mv $file $new_file
echo "mv $file $new_file"
done
fi
#####################################################################
# function read_dir(){
# for file in `ls $1` #$1表示函数第一个参数,$2表示第二个参数...
# do
# if [ -d $file ]
# then #递归调用 read_dir
# cd ./$file
# for file1 in `ls ../$file`
# do
# echo "pwd = `pwd`"
# echo "read_dir $file1"
# read_dir $file1
# done
# cd ..
# else #else is a file
# if [ "${file##*.}"x = "$TAIL1"x ]
# then
# main_name=`ls $file | cut -d . -f 1`
# new_file_name=${main_name}.${TAIL1_TO}
# echo "mv $file to $new_file_name"
# #mv $file $new_file_name
# fi
# if [ "${file##*.}"x = "$TAIL2"x ]
# then
# main_name=`ls $file|cut -d . -f 1`
# new_file_name=${main_name}.${TAIL2_TO}
# #echo "mv $file to $new_file_name"
# #mv $file $new_file_name
# fi
# #echo " $file is unknown file type!"
# fi
# done
# }
# read_dir $SOURCE_PATH