Subject: Replacing all \n with spaces doesn't work in GNU sed as expected

From: AlvinSeville7cf <[email-masked]>
Date: Wed, 4 Aug 2021 20:27:07 +1000

Hello! I want to read entire file and then replace all *\n* with space. 
My sed script is (I know that it is not optimal but it demonstrates 
problem):

|:a $! { N; ta } s/\n/ /g p |

So why even with *g* flag *s* command replaces only first *\n* in 
pattern space? For instance I have the following file:

|It was the best of times, it was the worst of times, it was the age of 
wisdom, it was the age of foolishness, |

The result of script execution is:

|It was the best of times, it was the worst of times, it was the age of 
wisdom, it was |

I use GNU sed 4.8. It seems to be a bug.