[shell programming] syntax
1. Declare variables
myUrl="http://see.xidian.edu.cn/cpp/linux/"
myNum=100
Note:
There cannot be a space between the variable name and the equal sign, which may be different from all programming languages you are familiar with.
At the same time, the naming of variable names must follow the following rules:
The first character must be a letter (a-z, A-Z).
There can be no spaces in the middle, and underscores (_) can be used.
Punctuation marks cannot be used.
You cannot use keywords in bash (you can use the help command to view reserved keywords).
2. Use variables
echo ${your_name}
Note: It is recommended to add curly braces to all variables. This is a good programming habit.
3. Redefine variables
myUrl="http://see.xidian.edu.cn/cpp/linux/"
echo ${myUrl}
myUrl= "http://see.xidian.edu.cn/cpp/shell/"
echo ${myUrl}
Note: You cannot write $myUrl="http:// during the second assignment. see.xidian.edu.cn/cpp/shell/", only add the dollar sign ($) when using variables.
4. Read-only variables
myUrl="http://see.xidian.edu.cn/cpp/shell/"
readonly myUrl
myUrl="http: //see.xidian.edu.cn/cpp/danpianji/"
Run the script, the results are as follows:
/bin/sh: NAME: This variable is read only.
五, Delete variables
After a variable is deleted, it cannot be used again; the unset command cannot delete read-only variables.
unset variable_name
6. Variable type
When running the shell, there will be three types of variables:
1) Local variables
Local variables are defined in scripts or commands, and are only defined in scripts or commands. Valid in the current shell instance, programs started by other shells cannot access local variables.
2) Environment variables
All programs, including programs started by the shell, can access environment variables. Some programs require environment variables to ensure their normal operation. Shell scripts can also define environment variables when necessary.
3) Shell variables
Shell variables are special variables set by the shell program. Some of the shell variables are environment variables and some are local variables. These variables ensure the normal operation of the shell
The above is the detailed content of [shell programming] syntax. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to remove duplicate values from PHP array using regular expressions: Use regular expression /(.*)(.+)/i to match and replace duplicates. Iterate through the array elements and check for matches using preg_match. If it matches, skip the value; otherwise, add it to a new array with no duplicate values.

Lambda expression is an anonymous function without a name, and its syntax is: (parameter_list)->expression. They feature anonymity, diversity, currying, and closure. In practical applications, Lambda expressions can be used to define functions concisely, such as the summation function sum_lambda=lambdax,y:x+y, and apply the map() function to the list to perform the summation operation.

The main differences between PHP functions and Shell functions are security (PHP functions are more secure), reliability (Shell functions vary by operating system), functionality (Shell functions are more powerful but limited by the shell), and performance (PHP functions are usually faster) and complexity (Shell functions are more complex). They are both used for file system, process and command operations, but PHP functions are built-in, while Shell functions are called through an external shell. Therefore, in server file download scenarios, the file_put_contents() function is safer, while the wget command is more flexible.

1. Programming can be used to develop various software and applications, including websites, mobile applications, games, and data analysis tools. Its application fields are very wide, covering almost all industries, including scientific research, health care, finance, education, entertainment, etc. 2. Learning programming can help us improve our problem-solving skills and logical thinking skills. During programming, we need to analyze and understand problems, find solutions, and translate them into code. This way of thinking can cultivate our analytical and abstract abilities and improve our ability to solve practical problems.

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid

C++ programming puzzles cover algorithm and data structure concepts such as Fibonacci sequence, factorial, Hamming distance, maximum and minimum values of arrays, etc. By solving these puzzles, you can consolidate C++ knowledge and improve algorithm understanding and programming skills.

C is an ideal language for beginners to learn programming, and its advantages include efficiency, versatility, and portability. Learning C language requires: Installing a C compiler (such as MinGW or Cygwin) Understanding variables, data types, conditional statements and loop statements Writing the first program containing the main function and printf() function Practicing through practical cases (such as calculating averages) C language knowledge

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).
