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: 
First, you can debug your functions by loading them into `ghci` and playing with them there. 

Then, you can use `trace` from [`Debug.Trace`](http://hackage.haskell.org/packages/archive/base/latest/doc/html/Debug-Trace.html) to print a string when an expression is evaluated. However be aware that since Haskell uses lazy evaluation, in most cases an expression will be evaluated at a different time than you'd expect. See also [Wikibooks](http://en.wikibooks.org/wiki/Haskell/Debugging) and [Haskell wiki](http://www.haskell.org/haskellwiki/Debugging#Printf_and_friends). (Internally `trace` uses unsafe calls that allow it to print output even within pure code. Normally you're not supposed to use them, but in this particular case it is OK.)
Approximation:

1. GHCi debugging is the way to print local variables without cluttering your code.
2. A WriterT monad transformer, either strict or lazy, can serialize your logs if you return your traced value, paired with the result.

```
{-# LANGUAGE PackageImports #-}
-- import qualified "transformers" Control.Monad.Trans.Writer.Strict as W
import qualified "transformers" Control.Monad.Trans.Writer.Lazy as W

compute:: Int -> Int -> (Int, Int)
compute x y = (result, local)
  where
    local = 2 * x
    result = local + y

test :: (Monad m) => W.WriterT String m Int
test = do
  let (r1, local1) = compute 5 3
  W.tell $ "local1= " ++ show local1 ++ "\n"

  let (r2, local2) = compute 2 2
  W.tell $ "local2= " ++ show local2 ++ "\n"

  return $ r1 + r2

main = do
  (r, logs) <- W.runWriterT test
  putStrLn logs
  putStrLn $ "result= " ++ show r

```

outputs:

```

local1= 10
local2= 4

result= ...

```