Is there a way in grep/egrep to extract tricky patterns from this text, insert them at the start of a line with its line remainder, so that it looks like the following?
Raw text that has been extracted from many files which have the word “nonspecific”. Now I need to organize these so that the names start at the start of the line so that they are easier to read. It would help to insert a blank line in between them as well but that may be not possible in egrep?
Input:
SofasCouchesChairs/Type1234567.xml:Nonspecific Couch-W ISSUESTablesDesks/Type123765.xml:Nonspecific Tables issues BedsDivans/Type4567345.xml:Nonspecific bed abnormalitiesBedBugs/Type2893993.xml:Nonspecific bugs in the spring boxes related to the mattressBed_Sofas/Type1317994.xml:Nonspecific WR abnormalities these are from Radios_TV/Type1274978.xml:radiation perhaps with nonspecific cell phones and cell towers Cabinets_TelephoneWires/Type1299691.xml:DATA:all kinds of nonspecific cell phone wave changes, with a
Expected output:
SofasCouchesChairs/Type1234567.xml:Nonspecific Couch-W ISSUES
TablesDesks/Type123765.xml:Nonspecific Tables issues
BedsDivans/Type4567345.xml:Nonspecific bed abnormalities
BedBugs/Type2893993.xml:Nonspecific bugs in the spring boxes related to the mattress
Bed_Sofas/Type1317994.xml:Nonspecific WR abnormalities these are from
Radios_TV/Type1274978.xml:radiation perhaps with nonspecific cell phones and cell towers
Cabinets_TelephoneWires/Type1299691.xml:DATA:all kinds of nonspecific cell phone wave changes, with a
See comments; the input is actually:
You can double space your output to match the expected output:
An aside, if your are trying to make things easier to read, you can experiment with the number of G’s. For example, this will triple space your file:
Also, to make the changes directly to your file, you can using the
-iflag (this saves us from having to unnecessarily createoutput.txt):