Actually based on your reply using the () and no 2 etc, I think I should have used a fuller example. My mistake, I had thought the answer to my simplified question would have been enough.
I have a script
Pattern=' [A-Z] \/Group\/Subgroup\/[.]*\/'
# $interim is generated by a special svn log command
cat $Interim | sed "s/$Pattern/.\//g" | sed "s/.src//g" | sort | uniq -u >$Unique
I am happy to use a fully in-line style as follows
cat $Interim | sed "s/ [A-Z] \/Group\/Subgroup\/[.]*\//.\//g" | sed "s/.src//g" | sort | uniq -u >$Unique
I'm trying to see how I can integrate the provided solution into my wider example. Wish I had shown the fuller answer, was hoping I could apply it to my issue.
Many thanks
---------- Post updated at 10:13 AM ---------- Previous update was at 08:42 AM ----------
Hello Franklin52 and everyone else.
One thing that confuses me is that the following pattern
[a-zA-Z0-9_]*
Doesn't seem to work correctly, I thought the * meant that any number or none of the characters were matched. So why would hhh_bbb be processed and hhh be ignored?
Im still having problems integrating the solutions into the fuller example I gave. I am unable to use php as it's not on the server. I could use perl but would really like to understand why the underscore is making things so tricky. I realise HP-UX sed isn't normally as fully featured as other versions.
Thanks
---------- Post updated at 10:22 AM ---------- Previous update was at 10:13 AM ----------
Let me share a full problem so you can see more clearly;
Example file to process
A /Branch/Subbranch/x9_llll/something/xx/SourceA
M /Branch/Subbranch/x23_llll/else/dir/SourceB
M /Branch/Subbranch/x49/else/dir/subdir/SourceC
M /Branch/Subbranch/x1/else/dir/subdir/SourceD
As far as I can tell the pattern
[a-zA-Z0-9_]*
Should cope with both x11_lll and x11
When I remove the underscore I see a mixture of stripped down programs only and unprocessed lines as follows;
M /Branch/Subbranch/x24_lll/else/dir/SourceH
M /Branch/Subbranch/x24_lll/something/dir/SourceJ
./something/dir/subdir/SourceX
./else/dir/subdir/SourceY
When I keep the underscore the resultant file looks okay but misses all the lines that had x11 only (as opposed to x11_lll). In the last code fragment the last two lines are correct in final output im looking for.