I run this command to rsync some files from Windows (Cygwin) to my local NAS:
rsync -PaSq --delete -e "/cygdrive/C/cygwin64/bin/ssh -i keyfile -p XXXX" "/source/" admin@192.168.1.1:/destination/
I now want to highlight in red any error messages. By that I mean highlighting the errors from rsync once it connects and not the ssh connection errors.
So this ssh connection error message remains unchanged:
ssh_exchange_identification: Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.2]
But this is highlighted in red:
rsync: delete_file: unlink(test/test.txt) failed: Permission denied (13)
I've tried the following with no luck. Any ideas appreciated.
rsync -PaSq --delete -e "/cygdrive/C/cygwin64/bin/ssh -i keyfile -p XXXX" "/source/" admin@192.168.1.1:/destination/ | tput setaf 1; sed -n '/rsync:/p'
rsync -PaSq --delete -e "/cygdrive/C/cygwin64/bin/ssh -i keyfile -p XXXX" "/source/" admin@192.168.1.1:/destination/ | egrep --color '.*rsync:.*|$'
rsync -PaSq --delete -e "/cygdrive/C/cygwin64/bin/ssh -i keyfile -p XXXX" "/source/" admin@192.168.1.1:/destination/ | grep --color=auto '.*rsync:.*|$'