awk [ -F re] [parameter...] ['pattern {action}' ] [-f progfile][in_file...]

  • 获得普通外部变量 
  • [xingxing.dxx@30_28_6_20 ~]$ test='test code'
    [xingxing.dxx@30_28_6_20 ~]$ echo | awk '{print test}' test="$test"
    test code 
  • BEGIN快中获取变量

  • [xingxing.dxx@30_28_6_20 ~]$ test='test code'
    [xingxing.dxx@30_28_6_20 ~]$ echo | awk -v test="$test" 'BEGIN{print test}'
    test code
    [xingxing.dxx@30_28_6_20 ~]$ echo | awk -v test="$test" '{print test}' 
    test code
  • 获取环境变量
  • [xingxing.dxx@30_28_6_20 ~]$ awk  'BEGIN{for (i in ENVIRON) {print i"="ENVIRON[i];}}'
    TERM=linux
    G_BROKEN_FILENAMES=1
    SHLVL=1

     

相关文章:

  • 2021-11-08
  • 2021-11-12
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2022-01-27
  • 2021-08-22
  • 2021-07-20
  • 2021-06-28
  • 2022-12-23
相关资源
相似解决方案