replace - Comment out one line of many files with sed -


i need comment out line of many files on 1 path. line reads

input_types = ['text'] 

and need replace

#input_types = ['text'] 

i want like

sed -i 's/input_types/#input_types/g' path/to/files/* 

but change instances of input_types , don't want that.

i tried

sed -i 's/input_types = ['text']/#input_types = ['text']/g' path/to/files/* 

but didn't work

how can change specific instance?

you last try quite good, 2 things have changed:

  • you use single quotes enclose expression, single quotes part of expression -- gets confusing. in case it's better use double quotes enclosing expression, instead.
  • the [ ] brackets have escaped backslashes: \[ \]

so, if change line to

sed -i "s/input_types = \['text'\]/#input_types = \['text'\]/g" /path/to/files/* 

it should work.


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -