Hi. I have got a bit of a problem that I need some help with, and it has been bugging me all afternoon. I need to add the contents of a variable to every line in a text file, using a bash script. For example, if the original file contained:
and the variable contained something like "Hello", how would I go about producing something like this:
Code:
Hello World
Hello World
(I am not really concerned about the space in the middle.)
It has to use a variable, because the variable is taken from what the user types in to the computer.
I have so far tried using:
Code:
cat $VAR file1 | cat > file2
Returning:
Hello World
World
But I need the Hello on every line.
I have also tried:
Code:
sed 's/^/$VAR/g'
Returning:
$VAR World
$VAR World
I'm sorry if my question is a bit vague, but I really need help with this, and have tried everything I can think of. Thanks, in advance, for any advice or help given. It is greatly appreciated.