Add a prefix to each line when printing with a tee

I have a team like this

command | tee /dev/tty | grep ...

who say fingerprints

hello
world

I would like to change this so that each line from the output file of the command is prefix, in the output or in the form, say:

# hello
# world
+4
source share
1 answer

bash process substitution can help

printf 'hello\nworld\n' | tee >(awk '{print "#"$0}' > /dev/tty) | grep hello
hello
#hello
#world
+4
source

All Articles