Skip to main content
9 events
when toggle format what by license comment
Mar 10, 2018 at 14:32 history edited terdon CC BY-SA 3.0
added 1 character in body
Mar 10, 2018 at 14:30 comment added terdon @G-Man (1) you're absolutely right, no idea what I was thinking. It does actually produce the expected output with the OP's example, which is why I didn't realize at the time. I wanted \n to leave other whitespace unchanged. (2) yes, but this shouldn't be done in the shell in the first place. I was going through a shell phase at the time and was interested in shell-only solutions. Silly though. (3) Why not? it's slow and inefficient, yes (see (2)), but if you're going for slow and inefficient (shell) anyway, why not?
Mar 10, 2018 at 4:57 comment added G-Man Says 'Reinstate Monica' (1) IFS="\n" doesn’t work.  (Perhaps you meant IFS=$'\n'? But why not just IFS=?)  IFS="\n" seems to be equivalent to IFS=n.  If a line of input contains exactly one n, and it is the last character on the line, it will be stripped.  (Try your name, for example.)  (2) Your script fails in the pathological case that the last line of the input doesn’t end with a newline.  (3) Seriously?  You’re using expr?  In a loop?
Oct 31, 2014 at 17:30 comment added Basil Thanks, like you said in chat: ugly, but functional and portable ;)
Oct 31, 2014 at 17:29 vote accept Basil
Oct 31, 2014 at 17:23 history edited terdon CC BY-SA 3.0
added 360 characters in body
Oct 31, 2014 at 16:52 history edited terdon CC BY-SA 3.0
deleted 5 characters in body
Oct 31, 2014 at 16:51 history edited cuonglm CC BY-SA 3.0
deleted 2 characters in body
Oct 31, 2014 at 16:50 history answered terdon CC BY-SA 3.0