I want to read lines of a file line by line, tokinize every line and do some processings. The file structure and script look like
[root@localhost:~] cat vms.txt
mahmood May 24
[root@localhost:~] cat power_offs2.sh
#!/bin/bash
INPUT=/vms.txt
while IFS= read -r line; do
echo "$line" | awk '{split($0,a,"|"); print a[1],a[2],a[3]}'
NAME=a[1]
NEW_MONTH=a[2]
NEW_DAY=a[3]
echo $NAME "-" $NEW_MONTH "-" $NEW_DAY
done < $INPUT
The output however is
[root@localhost:~] sh /power_offs2.sh
mahmood May 24
a[1] - a[2] - a[3]
It seems that array is defined in the awk scope. How can I fix that?