I have a script that outputs a column of text. I want to prepend each entry in the column with a string stored as a variable. How can I do this?
For example, consider the command
$ echo -e "john\npaul\ngeorge\nringo"
john
paul
george
ringo
Now, I'd like to prepend each entry in this column with the value of the environment variable $HOME
. I've tried piping into awk
like this:
$ echo -e "john\npaul\ngeorge\nringo" | awk '{printf("%s%s\n", $HOME, $1)}'
johnjohn
paulpaul
georgegeorge
ringoringo
This output is not what I'm looking for. What am I doing wrong?
$HOME
. Didn't mean to imply that I was echoing actual users, just wanted to choose some somewhat arbitrary text. – Brian Fitzpatrick Sep 05 '19 at 17:28