Split content based on keywords

I need to split the file contents with multiple rows based on patterns

Sample:
Input:

ABC101testXYZ102UKMNO1092testing
ABC999testKMNValid

Output:

ABC101test
XYZ102U
KMN1092testing
ABC999test
KMNValid

In this ABC , XYZ and KMN are patterns

[Mod} Double post. [Continue here./mod]

Community Rules

Try

sed -r 's/\BABC|\BXYZ|\BKMN/\n&/g' file

or

sed -r 's/ABC|XYZ|KMN/\n&/g;s/\n//' file
1 Like