软著中写源代码60页快速实现方法

来源:互联网 发布:数据挖掘毕业论文 编辑:程序博客网 时间:2024/04/30 08:33

软著中写源代码60页快速实现方法

原创 2016年09月26日 09:48:11

我们在写软著的时候,其中包含要写60页的源代码,包含前30页,后30页,代码帖的太麻烦,可以直接用脚本实现。而且可以快速统计代码行数,下面就用shell脚本实现一下。


[cpp] view plain copy
  1. #!/bin/bash   
  2. list_alldir(){  
  3. for file2 in `ls -A $1`  
  4. do  
  5. if [ -d "$1/$file2" ];then  
  6. #echo "$1/$file2"  
  7. list_alldir "$1/$file2"  
  8. elif [ -f  "$1/$file2" ];then  
  9.   
  10.     if [[ "$1/$file2" == *.cpp ]] || [[ "$1/$file2" == *.h ]] || [[ "$1/$file2" == *.pro ]];then  
  11.       
  12.   
  13.     echo "\n" >> out.txt  
  14.     echo "$1/$file2" >> out.txt  
  15.     echo "\n" >> out.txt  
  16.     cat "$1/$file2" >> out.txt  
  17.     fi  
  18. fi  
  19.     done  
  20. }  
  21. list_alldir ./Pcloud  

list_alldir就是列出文件目录下所有包含后缀.cpp,.h和.pro的文件。并把他们的内容写入到out.txt中,最后只需要统计out.txt的总行数即可,把代码贴到文档中即可。
原创粉丝点击