Created
May 28, 2017 15:29
-
-
Save LukeDemons/764ec6438ad4384c136deb727a7b3e16 to your computer and use it in GitHub Desktop.
申请软件著作权时,源代码处理脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read_dir() { | |
for item in $(ls $1) | |
do | |
if [ -d $1"/"$item ];then | |
read_dir $1"/"$item | |
else | |
file=$1"/"$item | |
suffix=${file##*.} | |
# which files do you want to append | |
if [[ $suffix != "sh" && $suffix != "css" && $suffix != "xml" ]];then | |
cat $file >> all.txt | |
echo $file | |
echo -e '\n' >> all.txt | |
fi | |
fi | |
done | |
} | |
$(touch all.txt) | |
$(cat /dev/null > all.txt) | |
read_dir $1 | |
# delete blanklines and comments | |
#sed -i 's/\/\*.*\*\///g' all.txt | |
#sed -i 's/\/\/.*//g' all.txt | |
#sed -i '/^$/d' all.txt | |
sed -i ":begin; /\/\*\*/,/\*\// { /\*\//! { $! { N; b begin }; }; s/\/\*\*.*\*\// /; };" all.txt | |
sed -i ":begin; /\/\*/,/\*\// { /\*\//! { $! { N; b begin }; }; s/\/\*.*\*\// /; };" all.txt | |
sed -i "/^[ \t]*\/\//d" all.txt | |
sed -i "s/\/\/[^\"]*//" all.txt | |
#sed -i ":begin; /<\!--/,/-->/ { /<\!--/! { $! { N; b begin }; }; s/<\!--.*-->/ /; };" all.txt | |
sed -i '/^[[:space:]]*$/d' all.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment