GNU bug report logs -
#73598
bug in sed Invalid preceding regular expression
Previous Next
To reply to this bug, email your comments to 73598 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#73598
; Package
sed
.
(Wed, 02 Oct 2024 13:00:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Peter Smulders <p.j.m.smulders <at> home.nl>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Wed, 02 Oct 2024 13:00:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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/\*\*\*\*//
---
The problem shows in:
$ sed --version
sed (GNU sed) 4.9
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jay Fenlason, Tom Lord, Ken Pizzini,
Paolo Bonzini, Jim Meyering, and Assaf Gordon.
This sed program was built without SELinux support.
GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed <at> gnu.org>.
----
an older version does not have this problem ( GNU sed version 3.02 )
best regards, Peter Smulders
Information forwarded
to
bug-sed <at> gnu.org
:
bug#73598
; Package
sed
.
(Wed, 02 Oct 2024 13:24:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
On Wed, 2 Oct 2024 11:59:09 +0200, Peter Smulders <p.j.m.smulders <at> home.nl>
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.
Information forwarded
to
bug-sed <at> gnu.org
:
bug#73598
; Package
sed
.
(Wed, 02 Oct 2024 15:21:06 GMT)
Full text and
rfc822 format available.
Message #11 received at 73598 <at> debbugs.gnu.org (full text, mbox):
I think I know already what is the matter. For to work properly double
escapes are needed, i.e.
echo ****some string | sed s/\\*\\*\\*\\*//
But I still find it strange ...
On 2-10-2024 15:00, GNU bug Tracking System wrote:
> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
> bug-sed <at> gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 73598 <at> debbugs.gnu.org.
>
> Please do not send mail to help-debbugs <at> gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
Information forwarded
to
bug-sed <at> gnu.org
:
bug#73598
; Package
sed
.
(Fri, 11 Oct 2024 10:39:03 GMT)
Full text and
rfc822 format available.
Message #14 received at 73598 <at> debbugs.gnu.org (full text, mbox):
Some further observations regarding the behaviour of regular expressions
in 'sed'
as noticed before the following is not accepted
$ echo ****somestring | sed s/\*\*\*\*//
sed: -e expression #1, char 8: Invalid preceding regular expression
but the following does
$ echo ****somestring | sed s/\\*\\*\\*\\*//
somestring
However, even this does not work anymore if the command is surrounded by
backquotes.
e.g.
$ name=`echo ****some string | sed s/\\*\\*\\*\\*//`
sed: -e expression #1, char 8: Invalid preceding regular expression
On the other hand the equivalent using $() is ok:
$ name=$(echo ****some string | sed s/\\*\\*\\*\\*//)
$ echo $name
some string
On 2-10-2024 16:50, Peter Smulders wrote:
> I think I know already what is the matter. For to work properly double
> escapes are needed, i.e.
>
> echo ****some string | sed s/\\*\\*\\*\\*//
>
> But I still find it strange ...
>
> On 2-10-2024 15:00, GNU bug Tracking System wrote:
>> Thank you for filing a new bug report with debbugs.gnu.org.
>>
>> This is an automatically generated reply to let you know your message
>> has been received.
>>
>> Your message is being forwarded to the package maintainers and other
>> interested parties for their attention; they will reply in due course.
>>
>> Your message has been sent to the package maintainer(s):
>> bug-sed <at> gnu.org
>>
>> If you wish to submit further information on this problem, please
>> send it to 73598 <at> debbugs.gnu.org.
>>
>> Please do not send mail to help-debbugs <at> gnu.org unless you wish
>> to report a problem with the Bug-tracking system.
>>
This bug report was last modified 247 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.