Perl - how to put to the next line if I have same pattern in one line

Dear All,

Could you help me how to put to the next line if I have pattern below in Perl language.

Data-123 Linux MacOSData-124 windows FreeBSDData-125 OpenBSD NetBSD

I would the output below:

Data-123 Linux MacOS
Data-124 windows FreeBSD
Data-125 OpenBSD NetBSD

Thank you very much
Askari

% echo 'Data-123 Linux MacOSData-124 windows FreeBSDData-125 OpenBSD NetBSD' |
perl -ne 's/Data/\nData/g && s/\n// && print'
1 Like

Hi Yazu,

Thank you so much.