Does bash have a cache to remember where it last found the binary?
Ok, so I play on my system. I copied the GNU word counting program:
cp /usr/bin/wc /usr/bin/wcx
and then I ran wc on a text file on my desktop and got the following as expected:
53 79 907 /home/me/Desktop/mytextfile.txt
so far nothing unusual. Then I remove (delete) wc
rm /usr/bin/wc
and the command returns without terminal output. Therefore, it was removed.
Now at this point I have to note that the PATH in this terminal is:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/bin:/sbin:/bin:/usr/games: [ETC]
Now when I run the same command:
wc /home/me/Desktop/mytextfile.txt
I'm coming back:
bash: /usr/bin/wc: No such file or directory
Now, obviously it won't be able to find the wc binary when I delete it. This is as expected. But curiously, bash seems to have "remembered" where on the PATH it last found the program, since it indicated that it could not find it in / usr / bin
Is this an actual bash specificity? Is there a cache that after it has searched the PATH for a binary once, it knows that it is returning to that location for future requests for that binary?
Thanks for helping clarify this!
source to share