Doing a migration my bit of code is
cat /etc/fstab |grep nfs >/root/mounts.txt
cat /etc/fstab |grep cifs >> /root/mounts.txt
rsync -av /root/mounts.txt ${REMOTEHOST}:/root/
ssh root@${REMOTEHOST} 'cat /root/mounts.txt >> /etc/fstab'
ssh root@${REMOTEHOST} 'for i in $(cat /root/mounts.txt |awk '{print $2}');do mkdir -p $i; done'
Problem is that the last line works locally:
for i in $(cat /root/mounts.txt |awk '{print $2}');do mkdir -p $i; done
However when I am passing it to the remote host I am getting:
awk: cmd. line:1: ^ unexpected newline or end of string"
Any suggestions to fix it?
'\''(single-quote backslash single-quote single-quote).