as stated, first learn the shell itself. (e.g. BaSH)
then practice scripting, once you can make fairly complex scripts, without too much hassle, then you can go into what you want to do. (a lot of trickery is needed, to not invoke the real issued commands, like e.g. "rm -rf /" etc..)
another approach could be to write a program, which emulates the commands behavior, by faking it.
This can be done in, e.g. Python, Perl, C