Skip to main content
deleted 12 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null- - infile </dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

n=/dev/null; paste -d\  "$n"- infile "$n"|- </dev/null | paste -sd\| - >outfile

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

n=/dev/null; paste -d\  "$n" infile "$n"| paste -sd\| - >outfile

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' - - infile </dev/null >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

paste -d\  - infile - </dev/null | paste -sd\| - >outfile
deleted 141 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

n=/dev/null; paste -d' |'d\ /dev/null /dev/null"$n" infile | tr"$n"| \\npaste \-sd\| - >outfile

Note that this will omit the final trailing \newline as is required for textfiles. You can sort that pretty easily, too, though:

echo >>outfile

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

paste -d' |' /dev/null /dev/null infile | tr \\n \  >outfile

Note that this will omit the final trailing \newline as is required for textfiles. You can sort that pretty easily, too, though:

echo >>outfile

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

n=/dev/null; paste -d\  "$n" infile "$n"| paste -sd\| - >outfile
added 1 character in body; added 10 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

So I had the whole thing wrong - and this question has taught me alota lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

paste -d' |' /dev/null /dev/null infile | tr \\n \  >outfile

Note that this will omit the final trailing \newline as is required for textfiles. You can sort that pretty easily, too, though:

echo >>outfile

So I had the whole thing wrong - and this question has taught me alot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

paste -d' |' /dev/null infile | tr \\n \  >outfile

Note that this will omit the final trailing \newline as is required for textfiles. You can sort that pretty easily, too, though:

echo >>outfile

So I had the whole thing wrong - and this question has taught me a lot about paste. As cuonglm correctly notes, unless you paste an in file in -serial, you'll always wind up w/ the last \newline from your infile list being appended to the output as it is written. I was mistaken in the belief that paste -s behavior was its default mode - and this is a misconception which, apparently busybox paste was happy to reinforce. The following command does work as advertised w/ busybox:

paste -d'|  ' /dev/null /dev/null infile >outfile

It does not work according to spec, though. A correctly implemented paste would still append a trailing \newline for each sequence written. Still, that's no big deal after all:

paste -d' |' /dev/null /dev/null infile | tr \\n \  >outfile

Note that this will omit the final trailing \newline as is required for textfiles. You can sort that pretty easily, too, though:

echo >>outfile
added 271 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading