Skip to content

Instantly share code, notes, and snippets.

@palytoxin
Forked from LukeDemons/append.sh
Last active November 17, 2021 06:35
Show Gist options
  • Save palytoxin/253371bc2710043299f2848665bb3dae to your computer and use it in GitHub Desktop.
Save palytoxin/253371bc2710043299f2848665bb3dae to your computer and use it in GitHub Desktop.
申请软件著作权时,源代码处理脚本
#!/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 != "png" && \
$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
# rule and test
# /* comment */
#sed -i 's/\/\*.*\*\///g' all.txt
# // comment
#sed -i 's/\/\/.*//g' all.txt
# # comment
sed -i '/^\s*#.*$/d' all.txt
# // "comment
sed -i "s/\/\/[^\"]*//" all.txt
# empty line
#sed -i '/^$/d' all.txt
sed -i '/^[[:space:]]*$/d' all.txt
# //
sed -i "/^[ \t]*\/\//d" all.txt
# <!-- comment -->
#sed -i ":begin; /<\!--/,/-->/ { /<\!--/! { $! { N; b begin }; }; s/<\!--.*-->/ /; };" all.txt
# /** */
#sed -i ":begin; /\/\*\*/,/\*\// { /\*\//! { $! { N; b begin }; }; s/\/\*\*.*\*\// /; };" all.txt
# /** */
#sed -i ":begin; /\/\*/,/\*\// { /\*\//! { $! { N; b begin }; }; s/\/\*.*\*\// /; };" all.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment