Chinaunix首页 | 论坛 | 博客
  • 博客访问: 383410
  • 博文数量: 138
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1620
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-10 16:55
个人简介

当你比别人优秀一点点,别人会嫉妒你。当你比别人优秀很多,别人会羡慕你。

文章分类

全部博文(138)

文章存档

2016年(2)

2015年(2)

2014年(15)

2013年(119)

我的朋友

分类: LINUX

2013-04-26 10:40:47


点击(此处)折叠或打开

  1. #!/bin/bash
  2. ###########################################################################################################################
  3. #Author: Dahuanxihuopusa@foxmail.com
  4. #Date: 26/04/2013
  5. #
  6. #Input: Two or Three
  7. #     Two:
  8. #        source case list file;
  9. #        success case list file
  10. #        
  11. #     Three:
  12. #        source case list file;
  13. #        success case list file;
  14. #        marked list file
  15. #    
  16. #     In two parameters case, a file named current time will be created. Then some blank line will be inserted into it,
  17. #     the line count depends on the line count of source list, they must have the same line count.
  18. #Output:
  19. #     The marked list file will be update. The line that both in souce list and success list will be
  20. # marked "y" in marked list, on the line corresponding to source list.
  21. ############################################################################################################################

  22.     if [ $# -eq 3 ]
  23.     then
  24.         source_line=`cat $2|wc -l`
  25.         result_line=`cat $3|wc -l`
  26.         if [ $source_line -ne $result_line ]
  27.         then
  28.             echo "source file and result file have different line count!\n"
  29.             exit
  30.         fi
  31.         result_file_name=$3
  32.     elif [ $# -eq 2 ]
  33.     then
  34.         source_line=`cat $2|wc -l`
  35.         # create a file with blank space, line count is as many as source file
  36.         result_file_name=`date -d "today" +"%Y%m%d-%H%M%S"`
  37.         touch ${result_file_name}
  38.         
  39.         while [ $source_line -ne 0 ]
  40.         do
  41.             echo " " >>${result_file_name}
  42.             source_line=$(($source_line-1))
  43.         done
  44.     else
  45.         echo "Wrong parameter count"
  46.         exit
  47.     
  48.     fi

  49.     # work code, before are useless infact
  50.     while read LINE
  51.     do
  52.         for single_line in `grep -n ${LINE} $2`
  53.         do
  54.             sed -i -e "${single_line%:*} c\y" ${result_file_name}
  55.         done
  56.     done<$1
脚本功能:
在execl表格中的列 4.2 中把已经success的case marke上y。




输入需要两到三个参数。
======================================================================================
两个参数的时候: 
参数一:整个case list
参数二:success的case list


脚本会以当前日期时间创建一个文件,文件包含 “整个case list文件行数”个空行。 创建的新文件的空行和整个case list一一对应。


运行完成后,包含在success case list中的case,会在空白文件对应行上marked 上y。


最后把结果文件全选复制,粘贴到 execl表格上 对应列的,第一个单元格行即可。原有的内容会被移到下面。


这种情况适合初次mark 的时候,原先内容为空。




======================================================================================


三个参数的时候,我们要提供一个已经有值的文件 marked list. 要求这个文件必须和整个case list 有相同的行。
这种情况下,我们一般是把execl表格中 marked 的那一列,复制到vi中,制作此文件。


运行结束后,marked list中的内容会被更新。 把原先的execl表格那一列删掉,把结果内容复制粘贴上即可。


这种情况适合后期更新,当有新的success list的时候,在已有的基础上更新execl 上对应的marked列。



阅读(1175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~