Put result of awk into an array

后端 未结 3 1386
北恋
北恋 2021-01-06 10:33

When I run the following command on terminal,

awk /984/ $files | awk -F, \'{OFS=\",\";print $1,$4,$17}\'

where,

         


        
3条回答
  •  一整个雨季
    2021-01-06 11:14

    To store variables in an array, output needs to be in a form like this:

    result=$(one two "more data")
    echo ${result[2]}
    more data
    

    Data separated by spaces. So tweak your output to give that format.

    Can you give an example of what you get out of:

    awk '/984/' $files | awk -F, '{OFS=",";print $1,$4,$17}'
    

    It may be shorten to:

    awk -F, '/984/ {OFS=",";print $1,$4,$17}' $files
    

提交回复
热议问题