Let's take a look at the asterisk assignment:
[Rocrocket @ rocrocket ~] $ Myvar = *
[Rocrocket @ rocrocket ~] $ Echo $ myvar
Apache-tomcat-5.5.26.tar.gz audiodump.wav desktop documents download dwhelper educonn.tar.gz music pictures public subversion-1.4.0-29.i586.rpm subversion-server-1.4.0-29.i586.rpm templates videos
-- The original * will be automatically replaced with the file list in the current directory.
In fact, the idea above cannot let us fully understand the essence. This is a shell knowledge point. Let us know.
Shell does not replace the file name when assigning values to variables. So when you execute x = *, only an asterisk is assigned to the X variable. The actual replacement occurs in Echo $ X.
The detailed steps are as follows:
1. When x = * is executed, shell scans the command line and assigns * to X.
2. When Echo $ X is executed, shell replaces $ X *
3. Shell replaces * with the file list in the current directory.
4 shell executes the echo command to pass the file list as a parameter to it.
This is the procedure. It is not difficult to remember: "variables are not replaced by matching values. Shell replaces variables first, file names, and finally processes parameters ".