Let me explain with an example:
I have a line where I declare an alias in my ~/.bashrc:
> grep lsdir ~/.bashrc
alias lsdir='ls -d */'
I have just added this line to my bashrc, and the alias is thus not yet added to my current session environment. I would also like not to re-source all my bashrc for some configuration reason, which is why I would like to simply run this grepped line on its own.
For the purpose of curiosity and education, I tried to do it without having to write it down manually, to no avail.
I tried this:
> $(grep lsdir ~/.bashrc)
bash: alias: -d: not found
bash: alias: */': not found
or this:
> "$(grep lsdir ~/.bashrc)"
bash: alias lsdir='ls -d */': No such file or directory
or even this:
> $("grep lsdir ~/.bashrc")
bash: grep lsdir ~/.bashrc: No such file or directory
But none worked. Is there any way to achieve this ?