awk split string code example
Example 1: awk '(split function)
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]}'
Example 2: awk split each character
echo "here is a string" | awk '
{
split($0, chars, "")
for (i=1; i <= length($0); i++) {
printf("%s\n", chars[i])
}
}'