Re: [dev] I didn't know that you could use the shell like this: compound pipe?

From: Jeremy <jer_AT_jer.cx>
Date: Wed, 17 Jan 2024 15:04:31 -0800

On 01/15/24 03:14PM, Greg Reagle wrote:
> I didn't know that you could use the shell like this. What a delightful surprise. Here is the code for bash/dash:
> ....
> command | (read -r; printf "%s\n" "$REPLY"; sort)
> ....

Thanks for sharing.
This is neat, however, it gets really gay when multiple processes buffer stdin.

For example, to comma-deliminate the header & sort output:

```
./program-cli --with-header --no-pager --output-file=/dev/stdout |
        (awk '{ IFS="\t"; OFS=","; print; exit }'; sort)
```

  :(


It's pretty clear that "header" information is just noise & should EITHER
be written:
        - if stdout is a tty
        OR
        - only to standard error

Jeremy
Received on Thu Jan 18 2024 - 00:04:31 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 18 2024 - 00:12:08 CET