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 set up an alias:

alias gpgagentexport="eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"

However when I source my .bashrc the $(cat ...) is evaluated at that point. But I want to evaluate it when I run the alias gpgagentexport (after the contents of ~/.gpg-agent-info has changed).

So is there some sort of escaping, quoting or syntax to achieve that?

share|improve this question
up vote 3 down vote accepted

Use single quotes:

alias gpgagentexport='eval $(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO'
share|improve this answer
Ah, thank you. I should go and read a bit more about bash quoting rules. – Hamish Downer Apr 13 '13 at 16:40

Escaping the $ should also work:

 alias gpgagentexport="eval \$(cat ~/.gpg-agent-info) ; export GPG_AGENT_INFO"
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.