Linux under ' DirName $ '

Source: Internet
Author: User

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:

  1. CD ' DirName $ '
  2. Echo ' pwd '

Then return to/home/admin/to execute

  1. SH test/test.sh

Operation Result:

  1. /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 $ '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.