I would like to make a script where, if a file is deleted in unix by any chance or by mistake, can it be recovered through a script... if yes what all commands will be needed. Could you please guide me in this case, to understand the concept.
Fine requirement. But to my knowledge files once deleted cannot be recovered as its removed from the memory once for all. If required we would be able to find if any files get deleted or not over a period of time.
The recovery process heavily depends on the way you backed up your files.
Without a backup an undelete is not possible with the tools a shell script provides. The data your files contained may still be on your disk, but the inode entries are discarded.