📜  awk 使用字符串作为字段分隔符 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:51:42.332000             🧑  作者: Mango

代码示例1
Just use function split in awk command to split a line into an array 'a'
using a choosen string as delimiter as for example ", " in next use case:
echo "hi, bye, hey" | awk '{split($0,a,", "); print a[3],a[2],a[1]}'
Or you could also do next:
echo "a, b, c" | sed 's/, /,/g' file.txt | awk -F ',' '{print $1 $2 $3}'