2 ms·
Sadly shell is not very good at string manipulation :-/ I would pipe the string to something like this and read it back into an array of lines (readarray):
by chubot 5y ago
Sadly shell is not very good at string manipulation :-/ I would pipe the string to something like this and read it back into an array of lines (readarray):
python -c 'print sys.stdin.read().split(", ")'
Or you can use sed and use read -d $'\x01':
echo -n "$mystr" | sed $'s/, /\x01/
That will handle newlines but not the 0x01 byte.
I think really a shell should have the ability to iterate over bytes/code points reasonably efficiently to do arbitrary string processing. Python isn't great at this either, since it creates a lot of 1 byte string objects.