I have a text file test.txt
with something like the following:
foo
configure
top
start
fun
bar
hello
I want to comment out line numbers 2, 5 and 7, so that the output would look like:
foo
#configure
top
start
#fun
bar
#hello
When I use sed -i "2,7 {s/^/#/}" test.txt
lines 2, 3, 4, 5, 6 and 7 get commented. How to ensure only specific line numbers are commented?
Appreciate any help.