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

Let me start by saying I know this was dumb. Time and Linux make fools of us all.

I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I still have a session open that has the aliases loaded (into the tcl?). Can I retrieve them from this session?

share|improve this question
What if you just type alias? It will show what you have defined. – fedorqui Jul 23 '14 at 15:04
Your next question is now required to be about setting up a backup system. :-/ – derobert Jul 23 '14 at 16:06
Your next task, as soon as you've recreated your .bash_aliases, is to set up version control for your dot files. – Gilles Jul 23 '14 at 23:02
@Gilles even better: unix.blogoverflow.com/2014/04/… – strugee Jul 24 '14 at 5:26
up vote 10 down vote accepted

You can almost definitely just do:

alias >>./bash_aliases
share|improve this answer

Easy trick

for alias in $(compgen -a); do type $alias; done
share|improve this answer
You, sir or madame, are a life saver. – MrUser Jul 23 '14 at 13:06
You are welcome :) – dchirikov Jul 23 '14 at 13:51
Combine this with redirection to a file ($alias > .bash_aliases, maybe with some file regexes to get it to the right place in the file) and you don't have to type it back into the original file yourself. (That is, if you haven't already typed it in.) – trysis Jul 23 '14 at 18:12
While this works, I don't see the benefit over just using 'alias'. The format isn't particularly useful by comparison. – moopet Jul 24 '14 at 8:01

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.