Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ssed is obsoleted by GNU sed anyway. It was a fork of GNU sed to test some experimental features that long since found its way back into the GNU sed. What distro are you using? I suppose, something Debian-based? Or is it FreeBSD? It seems nobody else packages ssed anymore. Unless it's a very old release like Debian 8 (Jessie) there's no point in using ssed.
It seems like you're trying to parse an XML/SGML document with sed. Please don't. sed is a line-oriented tool, HTML/XML/SGML is in no way line-oriented.
If \n is at the end of line your sed expression won't work, but sed can handle \n embedded into the string by other means, e.g. via its commands N and G.
Regular sed allows changing the line delimiter from \n to \0 (null character), using the -z option, but that was added in 2012 and the last release of super-sed appears to be 2005 so I guess it doesn't support that.
You could try comparing the codebases to see how much effort it is to update super-sed with new features.
Or, for this specific example that doesn't appear to be doing anything special, just use regular sed.
A regex is fine when parsing a single line, like it is here.
But I'd like to also remove the \r?\n. Without it, I end up with a blank line.
Again, sed does not see \n, because that is the delimiter. With other words: input is splitted into lines and sed commands work on these lines.
If you want to make sed work differently you need to check the option -z (see man sed).
xmlstarlet is also an option. Actually, it was my first choice, but it's picky about namespaces. E.g the sample GPX document from Wikipedia includes xmlns attributes, so you'll need to run it like this:
Because otherwise the .+ is likely to match to the end of the input before backtracking, whereas using accurate character classes will match only the characters needed, (which is both more efficient and makes intent clearer).
As various people have said, parsing markup with regex can be difficult and is not the best option - but there's a difference between handling wild HTML and simply removing lines from consistent well-formed XML - so this specific example is possibly ok - but if you're not 100% certain that's what you have and will always have, use a markup-aware tool instead.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.