GNU bug report logs - #49873
Replacing all \n with spaces doesn't work in GNU sed as expected

Previous Next

Package: sed;

Reported by: AlvinSeville7cf <alvinseville7cf <at> gmail.com>

Date: Wed, 4 Aug 2021 12:02:02 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: AlvinSeville7cf <alvinseville7cf <at> gmail.com>
To: 49873 <at> debbugs.gnu.org
Subject: bug#49873: Replacing all \n with spaces doesn't work in GNU sed as expected
Date: Wed, 4 Aug 2021 20:27:07 +1000
[Message part 1 (text/plain, inline)]
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.

[Message part 2 (text/html, inline)]

This bug report was last modified 3 years and 289 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.