I have a bash script containing multiple echo
calls:
#!bin/bash
echo 'a'
echo 'b'
echo 'c'
I want to prepend a default text to all of these echo calls to get an output like this:
default_text: a
default_text: b
default_text: c
Is there a way to do this globally inside the script without adding the default text to each one of the echo calls?
Note: Below there are 2 very good answers to this question. The one accepted resolves the problem specifically for echo
commands. The second one resolves the problem globally inside the script for any command that outputs to stdout.