The below command works in command line
rsync -avh -r /Source/09_03_2016/ /Destination/
echo $(basename !:3)
Output 09_03_2016
But when I do this in shell script it does not work
#! /bin/bash
/usr/bin/rsync -avh -r /Source/09_03_2016 /Destination/;
echo $(basename !:3)
Output !:3
;
at the end of thersync
command line in the script? – Kusalananda Oct 07 '16 at 09:46/Source/09_03_2016
! History expansion is meant for typing things quickly. It has no business obfuscating a script. – Gilles 'SO- stop being evil' Oct 09 '16 at 23:59