# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/(\S)(,)(\S)/\1\2 \3/gm;t' <<< "SELECT tbl_Generic_Tool.Generic_Type_ID, tbl_ref_Generic_Type.Generic_Type,
tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No ,Min(tbl_ref_Phase.Phase) AS FirstOfPhase,tbl_ref_Building.Building_Abbrev,tbl_ref_Status_Equipment.Status_Equipment
GROUP BY
tbl_Generic_Tool.Generic_Type_ID,tbl_ref_Generic_Type.Generic_Type,tbl_Hex.ODD_Micap,tbl_Hex.Hex_ID,tbl_Hex.Hex_No,tbl_ref_Building.Building_Abbrev,tbl_Hex.Status_Equipment_ID,tbl_ref_Status_Equipment.Status_Equipment
HAVING
(((tbl_Hex.ODD_Micap) < CONVERT(DATE,GETDATE()))
AND ((tbl_Hex.Status_Equipment_ID) = 2)))¦ AS H
LEFT JOIN tbl_POC_Assigned ON H.Hex_ID = tbl_POC_Assigned.Hex_ID
GROUP BY
H.Generic_Type
,H.Building_Abbrev
,H.ODD_Micap
,H.Hex_ID
,H.Hex_No
,H.Status_Equipment"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html