Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I add to ~/.bashrc the following code:

test_exclamation () {
  printf %s "$READLINE_LINE" | xargs echo
bind -x '"\eX": test_exclamation'

I write to bash prompt buffer

$ !1700

If I press Enter, then command with number 1700 from history performs. If I press Shift+Alt+X, I got an output:


How to change test_exclamation function to print command under number 1700?

share|improve this question
How is $READLINE_LINE defined? – Ketan Feb 10 '14 at 15:45
@Ketan - This is an built in BASH variable. Have a look at gnu.org/software/bash/manual/html_node/… – Loom Feb 10 '14 at 19:25
up vote 2 down vote accepted

Change it to

test_exclamation () {   READLINE_LINE=$( history -p "$READLINE_LINE" ) ;  }
share|improve this answer

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.