Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I delete a "word" in Bash, it will stop at certain characters like _ and /. For example, if I type


and activate backward-kill-word (typically mapped to Alt-Backspace and/or Ctrl-w), the remaining text is


. This does not correspond to $COMP_WORDBREAKS or readline's rl_completer_word_break_characters. How can I detect (preferably in a running system, rather than the defaults in the code, since they presumably can be overridden) which characters are used to determine word breaks?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The bash documentation states:

backward-kill-word (M-Rubout)

Kill the word behind point. Word boundaries are the same as those used by backward-word.


backward-word (M-b)

Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits).

The handling of backward-word in Bash 4.2 is done in the bundled libreadline code (text.c:rl_backward_word). The word break is based on rl_alphabetic, which itself relies on the isalnum function. This is locale-dependent, but not configurable directly in bash.

Note that Bash 4.0 introduced another "word" type with the shell-forward-word and shell-backward-word actions (and kill equivalents). These break only on shell meta-characters (()<>;&|") and blanks (possibly locale dependant via isblank), handled in the main bash code (bashline.c).

share|improve this answer
Good references, but that's rather vague. Do they mean [^A-Za-z0-9], [^[:alnum:]] (localization dependent) or something else? –  l0b0 Jun 11 '13 at 10:47
Strictly speaking, that's configurable with locales (the alnum character class) though that would affect other applications as well. –  Stéphane Chazelas Jun 11 '13 at 11:25
Ok, was looking at the wrong place in the code (shell-backward-*)... The split is based on isalnum, so indeed locale-dependent and equivalent to your second version, @l0b0. –  Mat Jun 11 '13 at 11:38
@Stephane Chazelas: I meant that it couldn't be configured via bash options, rephrased that bit. –  Mat Jun 11 '13 at 11:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.