Split string on a backslash (“\”) delimiter in awk?

后端 未结 5 1031
花落未央
花落未央 2021-01-14 17:56

I am trying to split the string in a file based on some delimiter.But I am not able to achieve it correctly... Here is my code below.

awk \'var=split($2,arr,         


        
5条回答
  •  猫巷女王i
    2021-01-14 18:43

    You don't need to call split. Just use \\ as field separator:

    echo 'a\b\c\d' | awk -F\\ '{printf("%s,%s,%s,%s\n", $1, $2, $3, $4)}'
    

    OUTPUT:

    a,b,c,d
    

提交回复
热议问题