Reuse command to connect in bash
I am using the following to indent the output of the configure script:
./configure | sed "s/^/ /"
Now I want to reuse part by pipe, so I don't have to write
./configure | sed "s/^/ /"
make | sed "s/^/ /"
make install | sed "s/^/ /"
I tried to put sed
in a variable like this:
indent=sed "s/^/ /"
and then do
./configure | indent
but it didn't work - how can i achieve this?
+3
source to share
3 answers
Use a BASH array to store the sed command:
indent=(sed "s/^/ /")
Then use:
./configure | "${indent[@]}"
make | "${indent[@]}"
make install | "${indent[@]}"
OR otherwise use the function for this sed command:
indent() { sed "s/^/ /"; }
Then use:
./configure | indent
make | indent
make install | indent
+7
source to share