When I run this at the command line it works correctly
awk 'BEGIN{FS=OFS=","}/^AAA/{$3="QQQ"}1' test.txt > newtest.txt
However when I try and run this in a bash script which SSH's in to a remote server it fails with a syntax error, but I can't see where it fails. It looks like it's pointing the the FS in the command.
I'm doing the following:
sshpass -p "password" ssh user@192.168.0.1 /bin/bash << EOF
echo password | sudo -u root -S awk 'BEGIN{FS=OFS=","}/^AAA/{$3="QQQ"}1' test.txt > newtest.txt
EOF
The SSH connection works fine, but the awk command fails. Any ideas how to resolve this ?
Thanks