Edit: Take a look at Michael’s explanation below. He seems to do a better job explaining eval than I did. 😐
I know this is an internal command, and I should probably wave it off as part of bash, but this one I use quite a lot. So I feel obligated to mention it.
eval interprets and expands a command before the shell can get its hands on it. That sounds cryptic, and in a way, it is.
But what that means is, eval will pass a command it finds elsewhere to the shell.
So let’s say, for example, you have a text file that tells feh what background image to use.
feh --bg-scale '/home/kmandla/wallpaper/1919x1199-malaria.jpg'
I like to give my wallpaper wacky names. Yes, that is the contents of the file. If you have a .fehbg file on your computer, it might look something like that in there.
How do we pump that into bash, to get feh started and doing its wallpaper thing? eval, of course.
eval `cat .fehbg`
And what does it do? eval takes the results of cat .fehbg and passes it to the shell. So, the contents of .fehbg are dumped through to bash, and we get a malarial background on the desktop.
What’s another example? Remember back when slmenu was the newest thing on the block, and not just a common everyday piece of software? Well, if you recall, slmenu’s output was just the selected string … probably a name for a program, but maybe not. Maybe with some arguments.
And how did that program get sent through to the shell, and slmenu to finally do its job? With eval, of course.