Can anybody explain to me how 'transaction' command works in a step by step written format?
If you read through this page, and the links coming off of it, you should get a good idea of how transaction works. http://www.splunk.com/base/Documentation/latest/Knowledge/Abouttransactions
You can also look at this example: http://blogs.splunk.com/2008/07/03/simple-transactions/