Home>Article>Operation and Maintenance> What does eq mean in linux

What does eq mean in linux

WBOY
WBOY Original
2022-07-13 11:14:24 5117browse

In Linux, eq means "equal"; Linux shell programming will use it to determine whether strings are equal, and "eq" can be used for integer comparison to perform conditional judgment and test whether two integers are equal. , if equal, the result is true, if not equal, the result is false, the syntax is "$A -eq $B".

What does eq mean in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

What does eq mean in Linux

In Linux shell programming, it is often used to determine whether strings are equal. The operator that can be used to determine whether strings are equal is '-eq'( equal), '-ne' (not equal to), '-lt' (less than), '-le' (less than or equal to), '-gt' (greater than) or '-ge' (greater than or equal to), and = ,==,!=,.

Command introduction:

Conditional judgment:

If the user does not exist

Add the user, give the password and display the addition successfully;

Otherwise,

Show if it is not there, it is not added;

variable name:

1, can only include letters, numbers, and lower lines, and cannot be able to not be able to Starting with a number;

2. It should not have the same name as an existing environment variable in the system;

3. It is best to be well-known by name;

How to do it in bash Implement conditional judgment?

Conditional test type:

Integer test

Character test

File test

Conditional test expression:

[ expression ] ` expression ` test expression

Integer comparison:

  • # - -eq: Test whether two integers are equal; for example, $A -eq $B

  • -ne: Test whether two integers are not equal; if not equal, it is true; if they are equal, it is false;

  • -gt: Test whether one number is greater than another number; greater than, True; otherwise, false;

  • -lt: Test whether a number is less than another number; less than, true; otherwise, false;

  • -ge: greater than or equal to

  • -le: less than or equal to

Expand knowledge

Logical relationship between commands:

Logical AND: &&

When the first condition is false, the second condition does not need to be judged, and the final result is already there;

When the first condition is true, the second condition must be judged;

Logical OR: ||

Recommended learning:

Linux video tutorial

The above is the detailed content of What does eq mean in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn