合并源代码到一个文件的脚本

最近公司申请知识产权,需要将提交前后各38页源代码,因此写了一个合并源代码的Bash脚本,如下所示:

#!/bin/sh

find . -name "*.java" -o -name "*.jsp" | while read file
do
if ! grep -q UTF $file; then
echo "Source File: $file"
cat -n $file
echo
fi
done

上面脚本中,源代码类型为 java 或 jsp

find . -name "*.java" -o -name "*.jsp"

不打印包含 UTF 的文件,是因为合并之后是乱码

if ! grep -q UTF $file; then

打印行号

cat -n $file

猜你喜欢

转载自codingstandards.iteye.com/blog/1595321
今日推荐