Ben Ben - 2 months ago 7
Linux Question

Adding a space between a match in Sed

8167656.COMTXSFR.COMXYSJZT.NET256079.COMG-BEI.NET256702.COM516073.COMWBMSR.COMWCRHC.COMWBRZD.COMWCFGR.COM571095.COM5770879.COMWBRTK.COMYWRTF.COMDZJZPX.COM5770819.COMSFCZH.COM8733918.COMHSPCF.COMSFXHT.COMXJFPX.COMWCRGT.COMWCKYR.COMWBRHM.COMWBRYG.COMWCRGX.COMFXTMY.COM1313661.COMBKRQC.COMBKSQC.COMBLLQC.COM6880797.COMWCKKR.COMWCJKR.COM516097.COMFPCYS.COMDKDZS.COMWIN2010.NETSFMWM.COMFSHUAYUE.NET001DAO.NETEXQUISITEGIFT.NETBANTLN.COMW363888.NET8848K.NETV6789.COMSZJIAHUA.NETICJY.NETSUPVAR.NETHUALINONLINE.NE


That's an example of what I'm working with. I need to add a space after
(COM|NET|INFO)
so the domains are readable. I've tried a few different ways, but can't seem to get it to work. The regex should be
(\.INFO|\.COM|\.NET)
right?

Answer

Try to escape pipes in pattern:

sed 's/\(INFO\|COM\|NET\)/& /g' file