Question: I'd like to split the following GST command into two halves using shell script.

`/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"Z0KAHukBQHpCAAAH0AAB1MAI\\,aM48gA\\=\\=\", payload=(int)96, ssrc=(uint)2416890621, clock-base=(uint)518578781, seqnum-base=(uint)24075`

The split has to occur at caps =
The two new lines should be stored in two variables $var1 and $var2

$var1 should contain
`/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink:`

And $var2 should contain
`application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, sprop-parameter-sets=(string)\"Z0KAHukBQHpCAAAH0AAB1MAI\\,aM48gA\\=\\=\", payload=(int)96, ssrc=(uint)2416890621, clock-base=(uint)518578781, seqnum-base=(uint)24075`

Remember there are two backslashes in the input string. So doing an echo will give only one backslash.

Answer: 
It is possible to quickly add impure debugging output to a pure function using the `trace` function of the [Debug.Trace](http://hackage.haskell.org/packages/archive/base/latest/doc/html/Debug-Trace.html) module. It is a function that returns its second argument with the additional side effect of printing the first argument when the second argument/returned value is forced.

I think it is totally acceptable to temporarily use this for debugging as long as it doesn't end up in any final commits or other permanent code. Also the order in which messages are printed matches the evaluation order which is also useful for debugging but not always the preferred order for the output.

If you need to use this very often it could also be a sign that you need to factor your code into smaller functions which makes it easier to inspect their behavior by just specifying arguments and looking at the return value.
There is a fairly short example [here](http://en.wikibooks.org/wiki/Haskell/Practical_monads#Generic_monads) of how to construct something that seems similar to what you describe. If I am reading it correctly, the author creates a simple monad that allows you to print out in the middle of computations, so to speak.