zoukankan      html  css  js  c++  java
  • awk用法

    grep:文本过滤器,
    grep "pattern" input_file ....

    sed: 流编辑器;
    sed "command/PATTERD/"

    awk:报告生成器。能够将输入的信息格式化之后显示;包括nawk版本,gawk版本

    用法:

      awk [option] 'script' file1 file2, ...
      awk [option] 'PATTERN {action}' file1, file2. ...
        print, printf

     1 root@ubuntu-ceph-07:~# echo  "this is a test" >>test.txt
     2 root@ubuntu-ceph-07:~# awk '{print $0}' test.txt
     3 this is a test
     4 root@ubuntu-ceph-07:~# awk '{print $1}' test.txt
     5 this
     6 root@ubuntu-ceph-07:~# awk '{print $2}' test.txt
     7 is
     8 root@ubuntu-ceph-07:~# awk '{print $1$2}' test.txt
     9 thisis
    10 root@ubuntu-ceph-07:~# awk 'BEGIN{OFS="#"}{print $1,$2}' test.txt
    11 this#is
    12 root@ubuntu-ceph-07:~# awk '{print $1,$2}' test.txt
    13 this is
    14 root@ubuntu-ceph-07:~# awk 'BEGIN{OFS=":"}{print $1, $2, $3, $4}' test.txt
    15 this:is:a:test
    16 root@ubuntu-ceph-07:~# awk 'BEGIN{OFS=":"}{print $1, $2, "AAAAAAA",$3, $4}' test.txt
    17 this:is:AAAAAAA:a:test

    地址:http://edu.51cto.com/lesson/id-17373.html

    meetup
    firebug

  • 相关阅读:
    枚举
    交房租
    Schtasks 命令详解
    记录自己在 cmd 中执行 jar 文件遇到的一些错误
    Java 8 日期时间 API
    Java 8 Optional 类
    Java 8 Stream
    Java 8 默认方法
    Java 8 函数式接口
    Java 8 方法引用
  • 原文地址:https://www.cnblogs.com/chris-cp/p/4665795.html
Copyright © 2011-2022 走看看