Can you use heredocuments to embed AWK in a bash script?

后端 未结 6 1235
庸人自扰
庸人自扰 2021-02-05 15:54

Writing a shell script that pretty much wraps around an Awk script. I\'d like to have my syntax colouring on in the awk section so I feel there must be a better way to embed awk

6条回答
  •  时光取名叫无心
    2021-02-05 16:36

    Not sure what you mean, but are you looking for something like this?

    #!/bin/bash
    
    awk 'BEGIN {
        print "hello world"
    }
    { 
        print $3
    }' <<< "$(df)"
    

    Have a look at 3.6.7 Here Strings in the bash manual

提交回复
热议问题