I have a question about the *
character at the end of a directory path in a bash script.
I have a script that's supposed to automatically delete some archives from a server once they get old enough. The script is on machine A and I need to run it on machine B. I access both machines remotely through ssh
(no sudo, just regular user). One of the rules of the script is that it needs to only delete archives in the folders beginning with dirA/dirB/dirC/dirD/dirE*
.
However, there is no dirE
in that location so I'm guessing the *
stands for some variable. This is what I'd like to know, what does the *
mean at the end of the directory path and what does it make the script do?
Best Answer
The
*
here is a "globbing character" and means "match 0 or more characters". To illustrate, consider this directory:As you can see above, the glob
dirE*
matchesdirE
,dirEa
anddirEEE
but notdirA
ordire
(*nix systems are case sensitive).So, in your script, that means it will delete archives from any directory in
dirA/dirB/dirC/dirD/
whose name begins withdirE
.