zoukankan      html  css  js  c++  java
  • grep piple & file

    please notice that the string appended to grep command should be piple or file name, should not be just a string.

    of course you can exploit the temp file for your resolution as possible as you can.

    dos copy --> right click

    Below is an example:

     1 #!/bin/bash
     2 
     3 #----------------------------------------------------------------
     4 # This script is used to extract the methods of the java class
     5 #-----------------------------------------------------------------
     6 cat java.java | while read line
     7 do
     8  #echo $line > temp.txt
     9  #grep "public class" temp.txt >> result.txt
    10  #grep "public.*{" temp.txt >> result.txt
    11  #grep "private.*{" temp.txt >> result.txt
    12  #rm temp.txt
    13  
    14  if [[ -n `echo $line | grep "public class"` ]]
    15  then 
    16      echo $line >> result.txt
    17  elif [[ -n `echo $line | grep "public.*{"` ]]
    18  then
    19      echo $line >> result.txt
    20  elif [[ -n `echo $line | grep "private.*{"` ]]
    21  then
    22   echo $line >> result.txt
    23  else
    24   echo hello
    25   continue
    26  fi
    27 done
  • 相关阅读:
    Java 调用存储过程、函数
    Java BaseDao
    写好Java代码的30条经验总结
    15款Java程序员必备的开发工具
    Oracle基础 表分区
    Oracle基础 索引
    Oracle基础 触发器
    Oracle基础 程序包
    Oracle基础 自定义函数
    Oracle基础 存储过程和事务
  • 原文地址:https://www.cnblogs.com/kelin1314/p/1964056.html
Copyright © 2011-2022 走看看