Please, if you could incorporate your answer into a working sed line.
Solution:
sed -r "s/([^]].*)\[/\1\r[/g" testfile.txt
Solution that handles both sides of the bracket, and removes tabs
sed -r "s/\t//g;s/([^]].*)\[/\1\r[/g;s/\]([^[].*)$/]\r\1/g" testfile.txt
I have this gnuwin32 (working) sed line:
sed -r "s/(.*)\[/\1\r[/g" testfile.txt
What it does is
s/
(.*)\[ - matches anyString[
/
\1\r[ - splits anyString<INSERTSCARRIAGERETURN>[
/g
What I'd like to do is use a ^ (NOT Operand) to exclude anyString from being a "]"
so...
before is pretty much this
*[
becomes
*
[
however...
if * == ]
, I'd like to not perform the operation.
It was suggested I do something like ^\[
However I don't know where/how to implement the ^
operator on a variable stringMask such as (.*)
. Does .*
being a string matter when I'm trying to text if *
is/ends with ]
?
I'm thinking either
(.*^\[)
or
(.*)^\[
any help would be appreciated.
Here's my sample data set
item_gloves
[OBJECT:ITEM]
###test###
[ITEM_GLOVES:ITEM_GLOVES_GAUNTLETS]###test###
[NAME:gauntlet:gauntlets]
###test###[ARMORLEVEL:2]
[UPSTEP:1]
###test###[SHAPED]
[LAYER:ARMOR]###test######test###
[COVERAGE:100]
[LAYER_SIZE:20]
[LAYER_PERMIT:15]
[MATERIAL_SIZE:2]
[SCALED]
[BARRED]
[METAL]
[LEATHER]
[HARD]