We can use any kind of http://www.aliyun.com/zixun/aggregation/18452.html "> text editor, such as Gedit, Kedit, Emacs, VI, to write the shell script, It must start with the following line (must be placed on the first line of the file):
#!/bin/sh ...
Note: It is best to use "!/bin/bash" instead of "!/bin/sh", if you use the TC Shell to TCSH, the other is similar.
The symbol #! is used to tell the system to execute the script, and this example uses/bin/sh. After the edit is finished and saved, if you want to execute the script, you must first make it executable:
chmod +x filename
Then, in the directory where the script is located, enter./filename to execute the script.
Quotation
The program expands wildcard characters and variables before passing any arguments to the program. The extension here means that the program replaces the wildcard character (such as *) with the appropriate filename and replaces the variable with the variable value. We can use quotes to prevent this extension, let's take a look at an example, assuming there are two JPG files in the current directory: Mail.jpg and tux.jpg.
#!/bin/sh
Echo *.jpg
The results of the operation are:
Mail.jpg tux.jpg
quotation marks (single and double quotes) prevent the extension of the wildcard *:
#!/bin/sh
echo "*.jpg" Echo ' *.jpg '
The results of the operation are:
*.jpg *.jpg
The single quotes are more restrictive, which prevents any variable from expanding, while double quotes prevent wildcard extensions but allow variable extensions:
#!/bin/sh
Echo $SHELL echo "$SHELL" Echo ' $SHELL '
The results of the operation are:
/bin/bash /bin/bash $SHELL
There is also a way to prevent this extension by using the escape character--the backslash: \:
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.