Each character is interpreted literally between single quotes, except for ' . Thus, you can put one quote inside such a line: 'single'\''quoted' is a single'quoted line.
Your command is complex because two shells are involved: the shell from which you run this command, and the shell in which su is run. Note that it is strange to run sudo su , since sudo already executes the specified command as root; sudo sh -c β¦ makes more sense. Therefore you need to specify for both. It is usually best to use single quotes for the outer shell, as well as double quotes or single quotes or backslashes for the inner shell.
You have another problem with your command: you are targeting the wrong file. /etc/profile read only by login commands, while the bind command is specific to bash, but must be read by all bash instances, not just login shells. Instead of writing this line to /etc/profile , you should write it to the system-wide bashrc , if any (usually /etc/bash.bashrc ).
sudo sh -c 'echo "bind '\''\"\\e[A\": history-search-backward'\''" >>/etc/bash.bashrc'
You can put this parameter directly in the readline configuration file, /etc/inputrc . You will save on citation level.
sudo sh -c 'echo '\''"\e[A": history-search-backward'\'' >>/etc/inputrc'
An easier way to pass an arbitrary string to a command would be to pass it as an input rather than an argument, and use a document here .
sudo sh -c 'cat >>/etc/inputrc' <<'EOF' "\e[A": history-search-backward EOF
Gilles
source share