Ok, I may not have a complete grasp on the problem, because I'm not encountering a problem with filenames having parentheses in them. So double check what I'm doing here. Here we go...
The expression, as you have it above, modifies the monitored data you have to this:
Code:
Opened Majora's Mask - 42 - Magic Hag's House.mp3
Title Updated
Opened 32 - Daughter of Madain Sari.mp3
Title Updated
Opened 09 - The Sons (Feat. Brett Reilly) - Too Much Of A Good Thing.mp3
Title Updated
Opened 08 - Liberi Fatali (FF VIII).mp3
That's the result I get from running the command on my system. So that's what I'm going to work with. If that's not the output you want, then we'll need to tinker with the expression some more.
I noticed the data alternates between "[DECODE]" and "[MAIN]" and those can serve as markers to prevent the "greedy" nature of an RE from getting too much. The modified version is:
Code:
msg=$( echo $line | sed 's%.*\[\(\(DECODE\)\|\(MAIN\)\)\] \(.*\)%\4%'
A couple things, I changed the format from "s///" to "s%%%". It's a little dizzying (to me) to see forward slashes and backslashes mingling. I'm not goinf to go so far as to say the new expression is clearer because of it, but oh well. Also, I added spaces to to suit my style.
So what does this beast of an expression do? It ignores anything until it comes to an open-close set of square brackets that contain either "DECODE" or "MAIN". It ignores the space immediately after the close square bracket, and returns everything following that space to the end of the line. So, on a fictitious data set of:
Code:
<10/03/05@17:38:04> [DECODE] Opened Majora's Mask - 42 - Magic Hag's House.mp3
<10/03/05@17:38:26> [MAIN] Title Updated
<10/03/05@17:39:34> [DECODE] Opened 32 [disc 1]- Daughter of Madain Sari.mp3
<10/03/05@17:39:57> [MAIN] Title Updated
<10/03/05@16:57:34> [DECODE] Opened 09 [disc 20] - The Sons (Feat. Brett Reilly) - Too Much Of A Good Thing.mp3
<10/03/05@16:57:56> [MAIN] Title Updated
<10/03/05@17:02:46> [DECODE] Opened 08 [disco [pt2]] - Liberi Fatali (FF VIII).mp3
The result would be:
Code:
Opened Majora's Mask - 42 - Magic Hag's House.mp3
Title Updated
Opened 32 [disc 1]- Daughter of Madain Sari.mp3
Title Updated
Opened 09 [disc 20] - The Sons (Feat. Brett Reilly) - Too Much Of A Good Thing.mp3
Title Updated
Opened 08 [disco [pt2]] - Liberi Fatali (FF VIII).mp3
So we're back at the original output except the expression doesn't get hung up on square brackets later in the filename. Like I said, if that's not exactly what you're looking for, we can refine the expression. It'll take some desired intput->output examples to flesh out the expression.