from:http://blog.163.com/wb_zhaoyuwei/blog/static/183075439201181553840490/
"'", learning to be called "inverted quotation marks", if enclosed in "inverted quotation marks", indicating that the need to execute the command.
Like ' DirName $ ', it means you need to execute dirname.
"" ", enclosed in double quotes, contains $ (dollar: denotes variable name) ' (inverted quotation mark: indicates execution command) \ (Escape number: means escape), and the remainder represents the string.
"'", enclosed in quotation marks, all of which represent strings, including the three special characters mentioned above.
It is meaningless to simply execute $ CD ' DirName $ ' in the command-line state. Because he returns the "." of the current path.
This command, written in a script file, returns the directory where the script file is placed, and can be used to locate the relative location of the program to be run (except for absolute locations).
The new test.sh content under/home/admin/test/is as follows:
- CD ' DirName $ '
- Echo ' pwd '
Then return to/home/admin/to execute
- SH test/test.sh
Operation Result:
- /home/admin/test
This allows you to know the location of the files deployed with the script, as long as you know the relative location can be based on this directory to locate, and can not care about the absolute location. This increases the portability of the script and can be executed on any server, if it is a deployment script.
Linux under ' DirName $ '