Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have an alias which attaches process named myprocess in gdb.

i.e. alias myat="gdb /path/to/myprocess $(pgrep myprocess)"
$ type myat
myat is aliased to `gdb /path/to/myprocess 23313'

This will work until myprocess dies and restarts with a new pid.
But, to be able to use the alias again, I have to reload my ~/.bashrc

Is there a better way of specifying this alias, so that I don't need to reload
~/.bashrc ?

share|improve this question
up vote 2 down vote accepted

The problem is that bash expands substitutions within double quotes (" ") at the time the alias ... command is run. Either escape the substitution as \$(...), or use single quotes (' ') instead.

alias myat="gdb /path/to/myprocess \$(pgrep myprocess)"
alias myat='gdb /path/to/myprocess $(pgrep myprocess)'

Or use a function instead:

myat() { gdb /path/to/myprocess $(pgrep myprocess); }
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.