rm command

how to retain file and directory after removing it with rm command

The only thing I can think of would be to replace "rm" with a script that simply moves the file or directory (you'd also have to replace rmdir, possibly others) into a safe holding directory, then have a scheduled job that removes files older than a week or a month...

If you've already deleted it, you will have to restore from backup - although there is a way to recover lost files (particularly text files).
Check out http://www.fish.com/tct/help-recovering-file for more info...

Good luck!