RT,很久以前写的拿出来骗一骗访问量
把sh文件扔进source里面运行sh *.sh
从子目录蒯出来:
#!/bin/bash
for file in ./*/*/*.cpp
do
name=${file##*/}
fa=${file#*/}
fa=${fa#*/}
fa=${fa%/*}
filename=${name%.*}
coder=${file#*/}
coder=${coder%%/*}
if test $filename = $fa
then
cp $file ./$coder/$name
fi
done
蒯进子目录:
#!/bin/bash
for file in ./*/*.cpp
do
mulu=${file%/*}
name=${file##*/}
sourcename=${name%.*}
if [ -a $mulu/$sourcename ]; then
if [ ! -d $mulu/$sourcename ];then
rm $mulu/$sourcename
mkdir $mulu/$sourcename
fi
else mkdir $mulu/$sourcename
fi
if [ ! -a $mulu/$sourcename/$name ];then
cp $file $mulu/$sourcename/$name
fi
done