shell history

When I try to run previous commands from the shell history, some irrelevent output is given (something like a script coding). What is the reason for this?

How are you trying to run these commands? What shell are you using? Different shells have different methods of accessing history and different files where the history is stored.