replacing by newline character

I have a file (pema)with a single long record which i have to break up into multiple lines
Input

s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc

Output

s1aaaaaaaaaaaaaaaaaaaaaaa
s1bbbbbbbbbb
s1cccccccccc

m planning to do it by replacing s1 by \ns1 \n is the new line character

i have tried

sed -e 's/s1/\n/g' pema > pema1
sed -e 's/s1/\/g' pema > pema1

but doesnt work...can any one help me :slight_smile:

Try:

sed 's/s1/\
&/g' pema > pema1
sed 's/s1/\ns1/g' filename

Try

echo "s1aaaaaaaaaaaaaaaaaaaaaaas1bbbbbbbbbbs1cccccccccc"|awk '{gsub("s1",RS);print}'
perl -pe 's/(?<=.)s1/\ns1/g' pema
1 Like

Thanks you all, woking great now