I use the following to indent the output of a configure script:
./configure | sed "s/^/ /"
Now I want to reuse the part behind the pipe, so I don't have to write
./configure | sed "s/^/ /"
make | sed "s/^/ /"
make install | sed "s/^/ /"
I've tried to put the sed
in a variable like this:
indent=sed "s/^/ /"
and then do
./configure | indent
but that did not work - how can I achieve this?
Use a BASH array to hold the sed command:
indent=(sed "s/^/ /")
Then use:
./configure | "${indent[@]}"
make | "${indent[@]}"
make install | "${indent[@]}"
OR else use a function for this sed command:
indent() { sed "s/^/ /"; }
Then use:
./configure | indent
make | indent
make install | indent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With