I want to comment out a line (add a #
to the beginning). I used this command: sed -i '96s/^/#&/' file.txt
on Linux to insert comment at line # 96.
If the line number is a variable, then how can I use this command? I have tried these commands:
(1)
sed -i '${line_number}s|^|#&|' file.txt
(2)
sed -i '${line_number}s/^/#&/' file.txt
But they don't work. How can I do this?