What I usually do from bash/vim ... is
- open file with vim
- go to line to comment
- comment a line
- save and quit
My file is /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini
and the initial content is
[xdebug]
zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
I want to run a command that in one statement adds ;
at the beginning of the second line.
[xdebug]
zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
Is it possible to do this directly from bash?
sed -i '2 s/^/;/' file
to add;
at beginning of 2nd line andsed -i '2 s/.//' file
to delete first character from 2nd line... see this for more such examples and this for use of-i
flag for different sed versions – Sundeep Oct 28 '16 at 13:57;
in question to show before and after example – Sundeep Oct 28 '16 at 13:58