How to handle CTRL+Z or CTRL+C in shells script?

Hi,
while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder.
How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to remove those files from the folder. Can we include this in the same script itself.

I dont want to add trap "" 2 20. Because at some point of time, i have to use ctrl+z or ctrl+c, so i need to clear the files after breaking the script.

Thanks in advance.
Chelladurai.

^Z doesn't "break" a script. It backgrounds it, and you can use fg to bring it back to the foreground.

I would use trap to handle the ^C press. It's not clear why you want to avoid it.

try add to these to beginning of the your script and then use the "CTRL-L" for remove files and exit from script

stty quit "^L"
trap "rm -f /yourfolder/* && kill -2 $$ " 3
......

regards
ygemici

Hi,
Thanks for you reply.
Because, if user kickoff the script, and then they want to stop means, they have to user ctrl+c or ctrl+z, thats y I avoided that part.

For Ex:
I executed the script, it will create 4 of 5 files, in the mean time I have stopped the script, while stopping the script, i should handle those unwanted files.

Thanks,