Put result of awk into an array

后端 未结 3 1485
北恋
北恋 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:09

    I think the problem is in the usage of () in your script. I tried a similar example and got the required output

    myarray=(`ls *.sh`)
    for f in ${myarray[@]} 
    do
        echo $f
    done
    

    I think the code of yours should be changed as follows

    result=(`awk /string/ $files | awk -F, '{OFS=",";print $1,$4,$17}'`)
    

提交回复
热议问题