3 ms·
In a POSIX shell, I actually prefer to use the bell character for IFS. while IFS="$(printf \\a)" read -r field1 field2... do ... done This works just as
by chasil 3y ago
In a POSIX shell, I actually prefer to use the bell character for IFS.
while IFS="$(printf \\a)" read -r field1 field2...
do ...
done
This works just as well as anything outside the range of printing characters.
Getting records that contain newlines would be a bit trickier.
- BenjiWiebe 3y agoI think IFS=$'\a' works too.
- thristian 3y agoOnly in bash and possibly other shells that extend the POSIX syntax, not in the basic POSIX standard.
- chasil 3y agoI seem to remember something about dash adding that functionality. ...I found it - the question is under review by the Austin group for inclusion in POSIX. https://austingroupbugs.net/view.php?id=249 https://austingroupbugs.net/view.php?id=249
- quesera 3y agoHeaven help you if you cat the file in a shell, though!