Sed not working in a predictable way on busybox

GNU SED can do a lot - sed on busybox can complain.
There is no proper documentation just short error messages like “Invalid contents of {}”.

Question:
Is there a way to translate proper SED commands in busybox on Turris Omnia?
Or is there a way to install proper GNU SED on Turris Omnia?
Is there any command documentation for SED on busybox?
Is there a syntax description for SED on busybox provided by OpenWRT of Turris Omnia?
I’d appreciate your help!
Looking forward to solutions.
/d

The sed utility provided with busybox is as they say a “very minimalist version of sed”. You can check its capabilities here: sed.c « editors - busybox - BusyBox: The Swiss Army Knife of Embedded Linux.

ls -l /bin/sed
lrwxrwxrwx    1 root     root             7 Apr  2 03:01 /bin/sed -> busybox
sed --version
This is not GNU sed version 4.0
sed --help
BusyBox v1.35.0 (2024-04-02 01:04:13 UTC) multi-call binary.

Usage: sed [-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...
or: sed [-i[SFX]] [-nrE] CMD [FILE]...

	-e CMD	Add CMD to sed commands to be executed
	-f FILE	Add FILE contents to sed commands to be executed
	-i[SFX]	Edit files in-place (otherwise write to stdout)
		Optionally back files up, appending SFX
	-n	Suppress automatic printing of pattern space
	-r,-E	Use extended regex syntax

If no -e or -f, the first non-option argument is the sed command string.
Remaining arguments are input files (stdin if none).

Looking at the Makefile of the OpenWRT package however you can see it provides GNU sed.
Just install it with opkg and you will get GNU sed.

opkg update
opkg install sed
ls -l /bin/sed
lrwxrwxrwx    1 root     root            20 Jun  9 17:16 /bin/sed -> /usr/libexec/sed-gnu
sed --version
sed (GNU sed) 4.8
Copyright (C) 2020 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@gnu.org>.
5 Likes

Thank you for your successful help!
Just installed GNU sed with opkg and I got GNU sed!
Actually this is the way to get proper GNU sed.
First tests look promising: No longer getting weird error messages .

Thank you!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.