Ubuntu – Why won’t Ubuntu Terminal accept “\” character

command line

I can't get my terminal shell to accept a \ when I type it in. Nothing happens. I've Googled but haven't seen anything which seems to address this. I have no idea where I would start to trouble shoot.

EDIT:

I can use the \ in eclipse, any text editor (including nano or other command line tools). The exact command in question is:

find -type f -exec chmod -x {} \;    

If I copy and paste that line in, the \ character disappears. If I then try and type it in, nothing happens.

The only place this is a problem is int he actual shell command line.

Thanks.

EDIT TWO:

Seems to be some confusion. If I copy the above command onto my command line, WITHOUT PRESSING ENTER (I.E not executing) This is what is in my shell:

$find -type f -exec chmod -x {} ;    

If I then try and enter a \ to escape the ; the symbol Does not Appear. If I press enter at any time while this command has been entered in the above circumstances it FAILS to execute, due to the ; not being passed into the command.

Edit 3:

I'm using GNOME 3.4.1.1 on Ubuntu 12.04 LTS

Best Answer

One possibility is that the backslash key has become bound to some readline command (readline is the library that allows in-situ editing of shell commands, for example binding Ctrl+h to the backward-delete-char action).

To test if that might be the case, you can try starting a bash subshell with readline editing disabled

bash --noediting

If the backslash key works in that subshell, then the places to look for the rogue keybinding definition would be /etc/inputrc for the global configuration and ~/.inputrc for per-user configuration. You could also try printing out and searching the currently defined keybindings from the command line using

bind -P | grep '\\\\'

The extra backslashes are required because a literal backslash will appear in the readline configuration as \\, each of which needs a further escape in the shell. Obviously you can only do that in the subshell, if the backslash is being bound in the regular shell.

FYI there is a bind command option to remove a binding, but it is not clear how to input the keyseq argument when it is already bound

-r  keyseq         Remove the binding for KEYSEQ.

For further information see help bind in the bash command line

Related Question