(Linux shell) Chapter 1-test the knife (below) and test the knife

Source: Internet
Author: User

(Linux shell) Chapter 1-test the knife (below) and test the knife

Source: (linux shell) Chapter 1-test the tool (below)


1.6 arrays and associated Arrays

1.6.1 prerequisites

Bash supports both common arrays and associated arrays. Common Arrays can only use integers as array indexes, while associated Arrays can use strings as array indexes. Associated arrays are useful in many operations.

1.6.2 practical drills

There are many ways to define arrays. You can use a column of values in a single row to define an array:

Array_var = (,) # these values are stored in the continuous position where the index starts with 0.

In addition, you can define an array as a set of index-values:

Array_var [0] = "test1"

Array_var [1] = "test2"


Print the content of a specific array element:

Echo $ {array_var [0]}

Print all values in the array as a list:

Echo $ {array_var [*]}

Print array Length

Echo $ {# array_var [*]}


1.7 use aliases

1.7.1 prerequisites

Aliases can be easily used by using functions or alias commands.

1.7.2 practical drills

Alias new_command = 'COMMAND sequence'

Alias install = 'sudo apt-get install'

Of course, the modified alias is only temporary and only valid for the current terminal. if you want to maintain the effect, you can put it in ~ /. Bashrc


1.8 obtain terminal information

1.8.1 preparations

Tput and stty are two terminal processing tools.

1.8.2 practical drills

Obtain the number of rows and columns of a terminal.

Tput cols

Tpu lines


Print the name of the current terminal:

Tput longname

Move the cursor to the position (100,100)

Tput cup 100 100

Set terminal background color

Tput setb no (0--7)

Set the text style to bold:

Tput bold

Delete all content from the current cursor to the end of the line:

Tput ed

Use stty-echo to hide user input.


1.9 get the set date and latency

1.9.1 practical drills

Read Date:

Date

Print epoch

Date + % s

Option -- date is used to provide a date string as the input. However, we can use any date formatting option to print the output. The date string can be used as the input to know the given date is the day of the week.

Date -- date 'Jan 20 2011 '+ %

You can print the date format according to your selection:

Date "+ % d % B % Y"


You can run the sleep sec command to delay the time.


1.10 functions and Parameters

1.10.1 practice

Define functions:

Function fname (){

Statements;

}

Or fname () {statments}

You only need to use a function name to call the function:

Fname

Call function transfer parameters:

Fname arg1 arg2

The following is the syntax for function reading parameters:

Fname (){

Echo $1, $2 # access parameter 1 and parameter 2

Echo "$ @" # print all parameters at a time in the form of a list, that is, "$1" "$2" "$3"

Echo "$ *" # is similar to $ @, but the parameter is used as a single entity, that is, "$ 1c $ 2c $3". c is a character of IFS.

}


1.11 comparison and Testing

1.11.1 prerequisites

We can use if, if else and logical operators to perform the test, and some comparison operators to compare data items. Another test command can also be used for testing.

1.11.2 practice

If condition; then

Commands;

Fi

Arithmetic comparison

Conditions are usually placed in brackets. Note that there is a space between [or] And the operand. If you forget this space, the script will report an error. For example:

[$ Var-eq 0] or [$ var-eq 1]

Other important operators include:

-Gt: greater

-Lt: less

-Ge: greater than or equal

-Le: less than or equal

You can use the following method to test multiple conditions.

[$ Var-ne 0-a $ var2-gt 2] # logic and-

[$ Var-ne 0-o $ var2-lt 2] # logic or-o

File System tests:

[-F $ file_var] # returns true if the given variable contains a normal file path and file name

[-X $ var] # returns true if the given variable contains executable files

[-D $ var] # returns true if the given variable contains a directory.

[-E $ var] # returns true if the specified variable contains the object

[-W $ var] # returns true if the given variable contains writable content

[-D $ var] # returns true if the given variable contains readable content

[-L $ var] # returns true if the given variable contains a symbolic link



String comparison:

You can check whether two strings are equal and not equal:

[[$ Str1 = $ str2] [[$ str1! = $ Str2]

Compare the size of two strings:

[[$ Str1> $ str2] or [[$ str1 <$ str2]

[[-Z $ str1] returns true if str1 is a Null String

[[-N $ str1] returns true if str1 is a non-null string


Fantasy westward journey (for "small test "?)

That is a new fantasy skill for the small-sized Design of level 60 to level 59

Skill name
Knife Test

Usage level
Level ≤ 59

Effect
Damage to a single enemy HP = Self Rating + 80

Consumption
Magic value at 20

Note

Players with a level less than or equal to 59 can select this skill in the skill field after entering the battle.
This skill is not displayed in non-combat status

What is the maximum number of seconds for a fantasy westward journey test?

A knife can beat up to two monsters. It will automatically disappear after 50 levels. The effect of a knife is related to its own power attributes.

The answer is complete.

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.