Add text to the end of line

Seems simple but ive been searching for a good hour of so

I have a text file and would like to add a string to the end of line 5 ( as an example)

to ake tings hard the line number we have to add the text to is stored in a variable cunningly name $Line_to_append

any ideas on how this could be accomplished gerp, awk sed ???

any help would be gratefully appreciated

Not sure I understand completely, but try in awk :

cat file
line1
line2
line3
line4
line5
awk '/^line5/{$0=$0" :text to add"}{print}' file
line1
line2
line3
line4
line5 :text to add

Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, and adequate (representative) sample input and desired output data and the logics connecting the two, to avoid ambiguities and keep people from guessing.

Nevertheless, try

Line_to_append=5
String_to_append="string"
awk -vLN="$Line_to_append" -vSA="$String_to_append" ' NR == LN {$0 = $0 FS SA} 1' file

or

sed "$Line_to_append s/$/ $string_to_append/" file