zoukankan      html  css  js  c++  java
  • AWK

    1、==  !=  <  >  <=  >=

      awk '$1=="str"{print}' filename

      awk '$1>$2 {print}' filename

    2、~  !~

      awk '$1~/str/ {print}' filename

      awk '$1!~/str/{print}' filename

      awk '/^str/{print}' filename

      awk '/str$/{print}' filename

    3、&&  ||  !

      awk '$1=="str1" && $2=="str2"{print}' filename

      awk '$1~/str1/ || $2~/str2/ {print}' filename

    4、不同操作之间以“;”隔开

      awk '{a=$1; b=$2; print $3}' filename

    5、for循环(不同的操作块以“{}”隔开)

      awk '{for(i=1;i<=NF;i++) print $i}' filename

      awk '{a=$1;for(i=1;i<=NF;i++) {j=i+1; print j}; print a}'

    6、if...else

      awk '{if() print}' filename

      awk '{if() print; else print}' filename  或者  awk '{if(){print}esle{print}}' filename

  • 相关阅读:
    Linux文件权限
    Linux命令
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/mphyfin/p/2104998.html
Copyright © 2011-2022 走看看