I have a bunch of sed commands in a batch file which I run using -f.
/PATTERN1 /I,/;/s/^[ \t]*//g
/PATTERN1 /I{:a;/;/!N;s/\n/ /;ta;P;D}
s/\(PATTERN1\) \([ \tA-Za-z0-9,\"\']*\)(\(.*\))[ \t]*;[ \t]*$/\1 \2\3;/I
If I run
gsed -f sed-file.sed input-file
it seems that since there are multiple lines which have the same pattern match in, it runs the first and ignores the others. If I comment out the lines one by one they work fine in the file on their own, but if I run them uncommented it only processes the first match.
My example input file file is
not (this line);
pattern1 some text, ( some other text (5), some other text (6));
pattern1 this text
(
that text (6),
that text (7),
);
not this text either;
I would like it to look like this
not (this line);
pattern1 some text, some other text (5), some other text (6);
pattern1 this text that text (6), that text (7), ;
not this text either;
So, if I leave all the lines in the sed file uncommented (as above) then I get:
not (this line);
pattern1 some text, ( some other text (5), some other text (6));
pattern1 this text ( that text (6), that text (7), );
not this text either;
If I comment out the first 2 lines I get
not (this line);
pattern1 some text, some other text (5), some other text (6);
pattern1 this text
(
that text (6),
that text (7),
);
not this text either;
Where the first line with pattern1 in correctly has the surrounding brackets removed.
If I comment out the just the first line I get
not (this line);
pattern1 some text, ( some other text (5), some other text (6));
pattern1 this text ( that text (6), that text (7), );
not this text either;
Where the lines matching pattern1 are concatenated up to an including the semi-colon, but the surrounding brackets are no longer removed.
And if I comment out the last line I get the samne but the spaces are not removed...
not (this line);
pattern1 some text, ( some other text (5), some other text (6));
pattern1 this text ( that text (6), that text (7), );
not this text either;
And if I comment out the last 2 lines I get:
not (this line);
pattern1 some text, ( some other text (5), some other text (6));
pattern1 this text
(
that text (6),
that text (7),
);
not this text either;
Where the spaces are correctly removed on lines begining with pattern1 and ending in semi-colon.
How can I make sure all 3 seds are processed in order, but use the one command? Or am I going to have to run them seperately?