Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Lesson 4 of my Longco operation and maintenance (1)

Shulou Source: shulou.com Published: 2022-06-01 09:20:51 10月03日 Update

Variables for the bash feature:

Variable name: a continuous memory space name.

Variable value: the data stored in the variable name.

Naming rules:

1. Can only start with a letter or "_", cannot use a number, and can be followed by any letter, number, and underscore

two。 Strict distinction between case and case

3. See the name and know the meaning

4. Writing rules:

1) all uppercase

2) Hump style

5. Cannot be the same as a known variable name

Species:

Global variable (environment variable): acts on the entire shell process, including its child shell

Local variable: only acts on the shell of the current login, excluding the child shell

Local variable: acts only as a moneyable program segment, generally used for functions

Default global variables: $?, $#, $*, $@, $$,.

$?: expand the status of the last executed command

$#: position parameters, expressed in decimal system

$*: expand all parameters

$@

$

$0: expand the file name of the shell or shell script

$LANG: storage language

$PS1: command prompt

Use of variables:

Declare a local variable: VARNAME=VALUE

Undo variable: unset VARNAME

Declare the environment variable: export VARNAME

Export VARNAME=VALUE

Declare

-a: declare an indexed array

-A: declare an associative array

-I: declare integer variables

-l: declare variables and convert characters in variable values to lowercase letters

-u: declare variables and convert characters in variable values to uppercase letters

-x: declare variables and make them environment variables everywhere

-r: declare a variable as read-only

View environment variables: export, set, env,

Declare a local variable: local VARNAME=VALUE

To take effect permanently, you need to change the configuration file:

Common configuration files: / etc/bashrc, / etc/profile

Private configuration files: ~ / .bashrc, ~ / .bash_profile

Reload the configuration file: source .bashrc,. .bashrc

Tags: Variables files letters environment configuration function value and will global parameter command uppercase character local number array same underscore location memory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Tech Info Apple Linux vpn