Record the special variables in the shell script

1. Special location variables

Record special variables in shell scripts

Record special variables in shell scripts

About the above related variables introduction , You can also refer to the man manual, execute the command “man bash”, and then search for the keyword “Special Parameters” to see the explanation of the relevant variables.

2, bash shell built-in variable commands

bash shell contains some built-in commands. These built-in commands are invisible in the directory listing, they are provided by the Shell itself. Commonly used internal commands are: echo, eval, exec, export, read, shift.

(1) echo——output information on the screen
Common parameters are as follows:
Record special variables in shell scripts

(2) export——Convert custom local variables into global variables.
(3) Shift——Offset the position variable
If shift is written in the script, it will change the original corresponding to $1, $2… The variable content of is shifted backward by one by default, the original $2 becomes $1, and the original $1 is gone. You can also write “”shift 3” in the script, which means that it is shifted by three places. The original $4 will become $1, and $5 will become $2… Then, what if my positional variables are only two? The offset will be cyclically. Assuming that $1 corresponds to “a” and $2 corresponds to b, I wrote a line of “shift 5” in the script, then it will offset the cycles of $1 and $2, and the final result is $1 Corresponds to b.

For other infrequently used commands, if necessary, use Baidu on your own. I won’t explain it here.

3. Shell variable string

h2>

You can use the following table to understand the variable strings of the shell, or you can execute the “man bash” command and search for “Parameter Expansion” to find the relevant introduction.

Record shell The special variable in the script

Summary about the deletion of matches in the table above:

  • # means deleting the shortest match from the beginning;
  • ## means deleting the longest match from the beginning;
  • % means deleting the shortest match from the end;
  • %% means removing the longest match from the end;
  • A “/” means replacing the matched first string;
  • Two “/” means replacing the matched All strings.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5566 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.