• 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
  • 相关阅读:
    C# 批量图片合并工具(附源代码)
    C# 封装
    SQL语句基础
    c# My计算器源码
    炸酱面
    烧茄子
    Linux Desktop Entry 文件深入解析
    硬盘安装ubuntu
    使用C语言进行面向对象的开发--GObject入门[2]
    GObject对象系统 (1)
  • 原文地址:https://www.cnblogs.com/kelin1314/p/1964056.html
Copyright © 2020-2023  润新知