zoukankan      html  css  js  c++  java
  • awk参数解析

    # awk --help
    Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
    Usage: awk [POSIX or GNU style options] [--] 'program' file ...
    POSIX options:          GNU long options: (standard)
            -f progfile             --file=progfile
            -F fs                   --field-separator=fs
            -v var=val              --assign=var=val
    Short options:          GNU long options: (extensions)
            -b                      --characters-as-bytes
            -c                      --traditional
            -C                      --copyright
            -d[file]                --dump-variables[=file]
            -e 'program-text'       --source='program-text'
            -E file                 --exec=file
            -g                      --gen-pot
            -h                      --help
            -L [fatal]              --lint[=fatal]
            -n                      --non-decimal-data
            -N                      --use-lc-numeric
            -O                      --optimize
            -p[file]                --profile[=file]
            -P                      --posix
            -r                      --re-interval
            -S                      --sandbox
            -t                      --lint-old
            -V                      --version
    
    To report bugs, see node `Bugs' in `gawk.info', which is
    section `Reporting Problems and Bugs' in the printed version.
    
    gawk is a pattern scanning and processing language.
    By default it reads standard input and writes standard output.
    
    Examples:
            gawk '{ sum += $1 }; END { print sum }' file
            gawk -F: '{ print $1 }' /etc/passwd

    awk -F[分隔符] ‘/搜索的字符串/{print $0}’

    awk 命令不加-F选项,默认分隔符是空格

    例如:搜索系统空间使用的大小:

    # df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        3.9G     0  3.9G   0% /dev
    tmpfs           3.9G  4.0K  3.9G   1% /dev/shm
    tmpfs           3.9G  1.2M  3.9G   1% /run
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/sda2       9.8G  6.7G  2.6G  73% /
    /dev/sda3       209G  353M  198G   1% /data

    1、搜索系统根目录使用的空间大小

        #df -h |awk '/sda2/{print $4}'  

    2、提取系统使用空间的整数部分

        #df -h |awk '/sda2/{print $4}' |awk -F[.G] '{print $1}'

          2

  • 相关阅读:
    mysqldump备份数据库时排除某些库
    Dataguard后台进程解析
    mysql 查看所有存储过程
    Oracle 中的 TO_DATE 和 TO_CHAR 函数
    trunc的使用
    mysql now() sysdate() curdate()区别
    ORA-10456:cannot open standby database;media recovery session may be in process
    ORACLE 修改日志大小及增加日志成员
    Oracle 11gR2用gpnp profile存放ASM的spfile路径
    C语言malloc()函数:动态分配内存空间
  • 原文地址:https://www.cnblogs.com/carriezhangyan/p/9293622.html
Copyright © 2011-2022 走看看