Try:
sed 's/^/hello there is /' file1.txt > final.sh
Or if you have to use a variable:
printf '%s\n' "$var" | sed 's/^/hello there is /' > final.sh
If you don't mind losing empty lines, you could also do:
IFS='
' # split on newline
set -o noglob # disable glob
printf 'hello there is %s\n' $var > final.sh # invoke split+glob
For your actual problem:
sed "s/.*/UPDATE ownership SET library_id = 'u-wl' where doc_id = '&';/" < file1.txt |
sqlite "$PLAY_DB_DIR/library.db"
(note that it assumes the entries in the files don't contain '
or other special byte sequences in the sqlite language. If you can't get that guarantee, that would be a sqlite injection vulnerability at best).
Or if you need to output shell code to be executed later:
{
echo 'sqlite "$PLAY_DB_DIR/library.db" << "EOF"'
sed "s/.*/UPDATE ownership SET library_id = 'u-wl' where doc_id = '&';/" < file1.txt
echo EOF
} > final.sh
Which on your sample gives:
sqlite "$PLAY_DB_DIR/library.db" << "EOF"
UPDATE ownership SET library_id = 'u-wl' where doc_id = 'bibi.toto';
UPDATE ownership SET library_id = 'u-wl' where doc_id = 'jaja.bubu';
UPDATE ownership SET library_id = 'u-wl' where doc_id = 'vrtegbvtr.rvgtbtdtbvtd';
EOF
Or if you have to run one sqlite
command per query:
repl=$(cat << "EOF"
sqlite "$PLAY_DB_DIR/library.db" 'UPDATE ownership SET library_id = '\\''u-wl'\\'' where doc_id = '\\''&'\\'';'
EOF
)
sed "s@.*@$repl@" < file1.txt > final.sh
(this time in addition to a sqlite injection vulnerability, that becomes an arbitrary command execution vulnerability, if the file may contain single quote characters).
On your sample, that gives:
sqlite "$PLAY_DB_DIR/library.db" 'UPDATE ownership SET library_id = '\''u-wl'\'' where doc_id = '\''bibi.toto'\'';'
sqlite "$PLAY_DB_DIR/library.db" 'UPDATE ownership SET library_id = '\''u-wl'\'' where doc_id = '\''jaja.bubu'\'';'
sqlite "$PLAY_DB_DIR/library.db" 'UPDATE ownership SET library_id = '\''u-wl'\'' where doc_id = '\''vrtegbvtr.rvgtbtdtbvtd'\'';'