Meaning of * in bash

Hello,

What is the meaning of code?
the use of * and the "tree" seem unclear to me.

1
2
3
4
5
6
7
ls
for i in *
do 
 if [ -d "$i" ]
    then (cd "$i";tree)
 fi
done 

thanks
Last edited on
It's a wildcard character. Run echo * and you will see that it expands to the list of filenames in the current directory. You can also specify part of the filename. For example *.png will give you the list of all PNG files.
1.so in my case the
*
will be what ? the name of all my files in my current directory ?
2.what's with that "tree" over there I don't get it

Thank you
1. Yeah. You can check it out for yourself. Just run echo * from the command line to see what you get.

2. tree is a command. I don't have it installed so I haven't tested it but from what I read it will print the files in the current working directory (note that the working directory has been changed by the previous command cd "$i").
Last edited on
thank you
Topic archived. No new replies allowed.