Split content based on keywords


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 1 Week Ago
Split content based on keywords

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

Sample:
Input:
Code:
ABC101testXYZ102UKMNO1092testing
ABC999testKMNValid

Output:
Code:
ABC101test
XYZ102U
KMN1092testing
ABC999test
KMNValid

In this ABC , XYZ and KMN are patterns

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

Old 1 Week Ago
Try
Code:
sed -r 's/\BABC|\BXYZ|\BKMN/\n&/g' file

or
Code:
sed -r 's/ABC|XYZ|KMN/\n&/g;s/\n//' file

This User Gave Thanks to nezabudka For This Post:
Jairaj (1 Week Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Split content based on keywords Jairaj UNIX for Beginners Questions & Answers 6 6 Days Ago 06:57 AM
awk to print line based on two keywords cmccabe Shell Programming and Scripting 8 05-12-2017 12:36 AM
Split a file in more files based on score content paolo.kunder Shell Programming and Scripting 5 11-20-2013 05:29 AM
Extracting words and lines based on keywords seemad Shell Programming and Scripting 2 06-09-2013 10:24 PM
HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching biztank Shell Programming and Scripting 8 07-24-2012 11:44 PM
split file content into specific folders turki_00 Shell Programming and Scripting 7 07-03-2012 04:07 PM
split content and write to new record Jairaj Shell Programming and Scripting 8 02-14-2012 01:31 PM
Split the file based on the content arukuku Shell Programming and Scripting 6 02-03-2012 01:22 AM
copy range of lines in a file based on keywords from another file kaaliakahn Shell Programming and Scripting 6 01-25-2012 11:50 AM
Sorting lines based on keywords for MySQL script vivek d r Shell Programming and Scripting 4 01-06-2012 04:06 AM
split file content Jairaj Shell Programming and Scripting 6 09-09-2011 02:50 AM
Forwarding based on keywords in sendmail vostrushka UNIX for Advanced & Expert Users 2 07-19-2011 05:28 PM
How to keep appending a newly created file based on some keywords supreet Shell Programming and Scripting 6 06-02-2009 02:34 AM
split file depending on content Chaitrali Shell Programming and Scripting 4 11-14-2007 08:15 AM
Capture lines based on keywords nimo Shell Programming and Scripting 4 11-03-2005 09:40 PM