How would I add a value to a new variable in bash, so that when I echo the variable Emacs would run?

  • can you clarify what exactly you want/expect, what have you tried and what didn't work for you? – Jakuje Jan 10 '16 at 14:14
  • For example I would like to create a variable EDITOR and than add a value to it, so that with command echo $EDITOR, Emacs would open and I could write something in it – Helga Jan 10 '16 at 14:24

You can't make bash to invoke commands during echo as far as I know. If I understand well your question you are searching for alias keyword.

alias editor='emacs'
editor  # will invoke emacs

You can store the alias in your .bashrc or just edit on-the-fly as you wish.


Is this what you were looking for?

$editor          # This will invoke emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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