unix shell: replace by dictionary

后端 未结 3 650
走了就别回头了
走了就别回头了 2020-12-15 14:59

I have file which contains some data, like this

2011-01-02 100100 1 
2011-01-02 100200 0
2011-01-02 100199 3
2011-01-02 100235 4

and have s

3条回答
  •  盖世英雄少女心
    2020-12-15 15:54

    awk 'BEGIN {
     lvl[0] = "warning"
     lvl[1] = "error"
     lvl[2] = "critical"
     }
    NR == FNR {
      evt[$1] = $2; next
      } 
    {
      print $2, evt[$2], lvl[$3]
      }' dictionary infile
    

提交回复
热议问题