I'm looking for a sed
solution like the one here: Print everything after nth delimiter
sed -E 's/^([^\]*[\]){3}//' infile
but to extract the text before nth delimiter, instead of nth delimiter like the example. Something that works with all sed variants. And operate on all lines like the example.
The delimiter in this example is \
but could be for any other. Should work with any version of sed.
sed
implementation you are using, ii) show us an example input file and iii) the output you expect. We cannot help you parse data you don't show. You mention a delimiter, what is that delimiter? Should we guess you have\
as the delmiter? – terdon Nov 15 '23 at 13:02sed -E 's/(^([^\]*[\]){3}[^\]*).*/\1/' infile
. You can replace "" with a letter like "e" or a number and keeps running:sed -E 's/(^([^e]*[e]){3}[^e]*).*/\1/' infile
. So you are not willing to put the effort to elaborate your answer dude. – Smeterlink Nov 16 '23 at 06:53^
,abc
(or any other multi-char string),/
, (or whatever is used to delimit the regexp in the script), or'
(or whatever is used to delimit the whole script), for example - they'll all fail in different ways given some of those "any other" delimiter values, no matter which sed version you use. – Ed Morton Nov 16 '23 at 12:33