I am trying to run this:
ssh $server_name@$host_IP "for wal in $server_wal_archive_dir/*
do
fileD=$(ssh $server_name@$host_IP stat -c %y \"\$wal\" | awk \'{print \$1,\$2}\')
fileDate=$(date --date=\"$fileD\" +%s)
if [ $currentDate -gt $fileDate ]
then
ssh $server_name@$host_IP rm $wal
fi
done"
But it shows me this message:
awk: '{print
awk: ^ invalid char ''' in expression
stat: cannot stat `': No such file or directory
date: invalid date`""'
I know date error is because no value in $fileD
I have tried to figure it out escaping the single quotes but no luck, what is my mistake?
Thanks in advance
David