I am trying to copy the files not present in one directory to the other directory by using awk
diff -r dir1 dir2 | grep dir1 | awk '{$1=$2=$3 =""; print "cp \"./dir1/" substr($0,4) "\" ./dir2/"}' | sh
This works fine except that I also want to print the file that is being copied. Something like cp ./dir1/file1.txt ./dir2/
on stdout
How do I do this. I know it's simple but I can't figure it out. I tried tee
and echo
commands but in vain.