I have a file I named poscar1.cif, and I would like to insert the contents of a variable at a specific line in this file.
For example, line 24
You can use sed to do it, depending on your answer to dawg's question as
sed -i -e '24s/$/5.3827/' poscar1.cif
or if it's the pattern
sed -i -e '/_cell_length_a/s/$/5.3827/' poscar1.cif
The first goes to the line with the given number, the later will apply on any line that matches the pattern in the first set of slashes. In either case it will then "replace" the end of the line with the value between the final two slashes.