[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Allowing delimiters other than newline and NUL?
From: |
Peter Boughton |
Subject: |
Allowing delimiters other than newline and NUL? |
Date: |
Fri, 24 Jan 2020 17:13:25 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
Hello.
Every so often I find a task that would be easy with sed, if only I
could use a delimiter other than newline.
It can be achieved with a couple of tr calls to swap delimiters for NUL
character and using sed -z, for example...
cat input.txt | tr ',' '\0' | sed -z -e '...' | tr '\0' ','
...but I was thinking, *why* can't I just specify a delimiter directly?
Given the -z option exists the code must handle it in some fashion, so I
grabbed the source and had a look and I've ended up with a local copy
that simplifies the above to:
sed -d',' -e '...' input.txt
I think that's a useful feature - do others agree?
If so, should I go ahead and add docs+tests+etc and submit a patch?
Thanks,
Peter
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Allowing delimiters other than newline and NUL?,
Peter Boughton <=