I am trying to copy one file to other directory and getting error message while interrupt is called.
The Script :
#!/bin/bash
PATH=~/MkFile/
exitfn () {
trap SIGINT # Resore signal handling for SIGINT
echo ; echo 'Called ctrl + c ' # Growl at user,
cp ./BKP/temp.txt $PATH/backup.txt
exit # then exit script.
}
trap "exitfn" INT # Set up SIGINT trap to call function.ii
read -p "What? "
echo "You said: $REPLY"
# reset all traps##
trap - 0 SIGINT
Output :
./signal.sh
What? ^C
Called ctrl + c
./signal.sh: line 9: cp: command not found
Do you have idea what is wrong in this script ??