Subject: bug#73598: bug in sed Invalid preceding regular expression

From: Davide Brini <[email-masked]>
Date: Wed, 2 Oct 2024 15:23:03 +0200

On Wed, 2 Oct 2024 11:59:09 +0200, Peter Smulders <[email-masked]>
wrote:

> I expect the command line
>
> echo ****some string | sed s/\*\*\*\*//
>
> to strip the *'s and result in
>
> some string
>
> However I get the error message:
>
> sed: -e expression #1, char 8: Invalid preceding regular expression
>
> -----
>
> When the sed command is taken from a file it works as expected:
>
> $ echo ****some string | sed -f script
> some string
>
> where file script consists of the line
> s/\*\*\*\*//
>

In the command line version, the shell is stripping away your backslashes.
So you want:

echo ****some string | sed 's/\*\*\*\*//'

--
D.