Basic knowledge of shll script + automatic creation of Yum Repository

Source: Internet
Author: User

Shll script Basics

1. All scripts should end with (. Sh)


2. Generally, SH is used to execute the script. Sh is a soft connection of bash.

3. grant permission denied an X permission.

4. If the interpreter is not specified, it is the bash interpreter by default.

5. The statement must be written in the first line of the script :#! + Absolute path of the interpreter

6. interactive interfaces are not allowed during script execution.

7. In the shll script, [] is a logical judgment & is a logical language | the logic or meaning triggers the output on the right when the left side is false. If the left side is true, no output on the right side is provided !! : Logic or only one, and can only be on the rightmost side; on the right side is the logical language and logic or cannot exist at the same time (otherwise an error occurs)

8 [111 = 111] There must be spaces at both ends of the brackets, and spaces at both ends of the symbol in the middle can be used to judge whether the logic is true or false.

9 in the computer, a value = is called a value assignment, and two = is in normal understanding.

10 In the shll script,-GT indicates greater than-EQ indicates equal to-lt indicates less than-ge indicates greater than or equal

-Le indicates less than or equal

11 during the shll script execution, $0 is the path for executing your script.

$ * And [email protected] LIST Parameters of your script

$ #Obtain the number of your Script Parameters

12.() Two parentheses represent the C language {c Represents the system language} for computing Recognition

13 input redirection: <fof (any character can be taken) is written when fof ends and output to the screen. It is usually used to write menus and generate configuration files.

14 exit indicates the force termination script.

15 read: output the content written by the user to the commonly used command parameter read-P + User Name on the screen to num

In general, the first letter of the variable must be capitalized.

16 common test commands:-D to determine whether the target is a directory

-E: determines whether the target file or directory does not exist.

-F identifies the object as a file from time to time

-Z: determines whether the target file or directory is empty.

Echo $ {# + variable} to check whether there are any characters in the target (that is, whether the target file or directory is empty)

 

 

Automatic Yum repository Construction

 

Vim yum. Sh
Umount/dev/sr0
[-D/Media/CDROM] | mkdir-P/Media/CDROM
Mount/dev/sr0/Media
/CDROM
If [$? -Ne 0]; then
Echo "check whether the disc is inserted"
Exit
Fi
[-D/etc/yum. Repos. d] | mkdir-P/etc/yum. Repos. d
CD/etc/yum. Repos. D &&\
MV */tmp/
Cat>/etc/yum. Repos. d/local. Repo <fof
[Kuangsan]
Name = kuangsan
Baseurl = file: // media. CDROM
Gpgcheck = 0
Enabled = 1
Fof
Yum-y cleam all & Echo "Clear cache" if the preceding command is incorrect, yum-y cleam all & Echo "yum cleam"
Yum makecache & Echo "success"

 

Basic knowledge of shll script + automatic creation of Yum Repository

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.