Current location - Training Enrollment Network - Mathematics courses - How does linux shell compare the sizes of two integers?
How does linux shell compare the sizes of two integers?
The linux shell can use the following code to compare the sizes of two integers:

#! /bin/sh

Maximum value =9

Minimum value =8

if [ $max -gt $min ]

then

Echo 1

other

Echo 0

The ship does not bear the loading fee.

Digital comparison:

-EQ is equal.

-ne (unequal)

-gt is greater than (greater than)

-It's less than (less than)

-ge is greater than or equal to.

-le is less than or equal to.

Comparison of strings:

[$str 1 = $str2] is equal to

[ $str 1! = $str2] is not equal to

[ -z $str ]? An empty string returns true.

[-n $str] or [$str] non-empty string returns true.

Extended data:

Shell is the user interface of the system, which provides an interface for users to interact with the kernel. It receives commands input by users and sends them to the kernel for execution.

Shell command

Command line c

When the user logs into the Linux system, he can see a shell prompt, which marks the beginning of the command line. Users can enter any commands and parameters at the prompt. For example:

$ date

2 1 1 23 0 1:34:58 CST 1999

$

When the user logs in, he actually enters the shell, and the shell interprets the input command according to certain syntax and transmits it to the system. The first word entered in the command line must be the name of the command, the second word is the option or parameter of the command, and each word in the command line must be separated by spaces or tabs in the following format:

$ command option parameter

Baidu encyclopedia -Linux Shell