Reputation: 1740
I need to comment out a line of many files on one path. The line reads
input_types = ['text']
and I need to replace it by
#input_types = ['text']
I want to do something like
sed -i 's/input_types/#input_types/g' path/to/files/*
but that would change all instances of input_types and I don't want that.
I also tried
sed -i 's/input_types = ['text']/#input_types = ['text']/g' path/to/files/*
but it didn't work
How can I change only that specific instance?
Upvotes: 0
Views: 40
Reputation: 303
You last try was quite good, but two things have to be changed:
[ ]
brackets have to be escaped with backslashes: \[ \]
So, if you change the line to
sed -i "s/input_types = \['text'\]/#input_types = \['text'\]/g" /path/to/files/*
it should work.
Upvotes: 1