I know a little about sed. In /etc/nanorc I got bunch of settings with comments (eg:).
#bind ^K setting 1
#bind ^F whereis all
#bind ^J setting 3
So, I want to comment out only this setting to enable key CTRL+D in nano:
#bind ^F whereis all
I tried this but seems it doesn't work:
sed -ri "s/#bind ^F whereis all.*$/\bind ^F whereis all/" /etc/nanorc
Seriously, I don't know how to go with this.
Commenting out one line is much easier with a simple text editor, but regardless...
Your command doesn't work because
^
is a special regexp character, meaning "start of the line" (when not between[
and]
). So your regexp will never match, because you expect the start of the line to be in the middle of the line. Also, you escape theb
character in the replacement, which is not needed. Use this instead: