not successful, will not run the code after source.Modifies the first line of the test.sh script, becomes #!/bin/bash, and executes again./test.sh, the screen output is:./test.sh:line 2:pcy.sh:no such file or directoryHelloThus, in the case of #!/bin/bash, although source is unsuccessful, it still runs the Echo statement after source.But then I tried to run the Sh./test.sh, this time the screen output is:.
shell is the shell is a command interpreter. More than just the insulating layer between the operating system kernel and the user, it ' s also a fairly powerful programm ing language. There are two kinds of shell and command line shell of GUI. The shell manages your interactions with the operating system: waiting for your input, explaining your input to the operating system, and processing the output of a wide variety of operating systems. Different systems have different shells, such as
To become a flexible tool, a qualified script must provide additional information to describe the role of the script, how it is executed, and where it is executed. Like the command, the script also uses parameters. Switches and parameters increase reusability, reduce costs, and save time. Positioning parameters
There are three effective methods for Linux scripts to use parameters. First, use the positioning parameter. The script calls the parameter based on the location where the parameter appe
There is a very serious bash vulnerability on the web that allows hackers to send remote commands to the server to easily steal privacy information, while many friends are not aware of what bash is and what bash means, so the following knowledge literacy article will bring some help.
What's bash?
The basic syntax for BASH• The simplest example--hello world www.111cn.net!
• about input, output, and error output
The bash of variables in the Chinese language (and the similarities and differences between C languages)
The basic Process Control syntax in bash
• Use of functions
2.1 Simplest example--hello world!The first example of almost all the programmi
"]
When $ foo is empty, the above command becomes
[ = "bar" ]
Similarly, when the $ Foo package contains spaces:
[ multiple words here = "bar" ]
Both errors occur. So double quotation marks should be used to enclose variables:
["$ Foo" = bar] # It's almost perfect.
But! When $ Foo starts with "-", the problem persists. In the newer Bash, you can use the following method instead. [[the keyword can correctly handle blank spaces, spaces, strip, and
Linux programming-Bash variables-general Linux technology-Linux programming and kernel information. The following is a detailed description.
1. User-Defined variables
A user-defined variable consists of letters, numbers, and underscores. the first character of the variable name cannot be a number.
Like other UNIX names, variable names are case sensitive.
You can assign values to variables as follows:
Name = value
When referencing a variable, you must
Bash debugging experience bash is one of the most common shells in Unix/Linux operating systems. it is very flexible, working with awk and c ++ is exceptionally powerful. use a test script below www.2cto.com to demonstrate how to use bash to debug www.2cto. comtest. sh [plain] #! /Bin/bash...
The variables in bash1. User-defined variablesdefinition of a variableUser-defined variables consist of alphanumeric characters and underscores, and the first character of a variable name cannot be a number.As with other UNIX names, variable names are case-sensitive.For variables, the user can assign values as follows:Name = valuea reference to a variableWhen referring to a variable, you need to precede the $ sign, and the user can assign a value to each other (the value of one variable is assig
2nd articlesBasic Concepts
Name
Note the following rules:
It can only contain letters, numbers, and underscores, and cannot start with a number.
Case Sensitive
The name cannot be the same as the name of the system variable.
In addition, if you want to export the name as a global variable, it is best to use uppercase letters for the name. This is just a customary convention, not a strict constraint.Type
Almost all programming languages have the concept of variables, and
Author: Feng limei,Hua Qing vision embedded college lecturer.
This document compares and analyzes bash configuration files in linux.
1. There are two global configuration files.
/Etc/profile: This file sets the environment information for each user in the system. This file is executed when the user logs on for the first time. And collect shell settings from the configuration file in the/etc/profile. d directory.
/Etc/
1. What is shell?The operating system interface. The shell can call the corresponding hardware through the kernel.2. What is Bash?Bourne again shell (BASH) is actually a version of shell.3. BASH Shell functions:1) command compilation function (command history );2) command auto-completion function (press the tab key );3) alias function. For example, if alias LA =
Reprinted: http://www.bsdlover.cn/html/24/n-3224.html
BashInVariable1. User-Defined variablesA user-defined variable consists of letters, numbers, and underscores. the first character of the variable name cannot be a number.Like other UNIX names, variable names are case sensitive.You can assign values to variables as follows:Name = ValueWhen referencing a variable, you must add the $ symbol before it. You can assign values to each other between variables, for example:(The previous $ is a command
Enable Linux Bash command in Windows 10 preview 14316
The bash component is provided in Windows 10 preview version 14316, Which is disabled by default, to enable this function, first Select Start> Settings> Update and Security> for developers> developer mode, and then press Win + X, F Open "programs and functions", click "enable or disable Windows functions" on the left side, find and check Windows Subsyste
Linux learning path: Understanding shell, bash, and shellbashI. shell
The direct controller of computer hardware is the kernel of the operating system. Because of the importance of the kernel, as a user, we cannot directly operate the kernel, therefore, we need shell to call the application or double-click to open the installed application to communicate with the kernel. Shell is equivalent to an interface that connects the program to the kernel. or s
Bash is one of the most commonly used shells in Unix/Linux operating systems. It is very flexible and is exceptionally powerful in combination with awk and C ++.
The following uses a test script to describe how to debug using Bash:Test. Sh
#!/bin/bashecho "----------------begin-----------------"awk '{sum+=1} END{print sum}' test.shMAX=3for ((i = 0; i
1. Use bash-x
Bash
=" Qq20170913132705.png "alt=" Wkiol1m4wbcweth1aaabllzd3r0606.png "/>Destroying an arrayUnset Array_name[index]Exercise: Generate 10 random numbers to save in an array, take out the maximum and minimum valuesExercise: Generate 10 random numbers in an array, and find the sum of all random numbers labeled evenExercise: Write a script to define an array in which the elements in the array are all filenames ending in. Log in the/var/log directory, and the sum of the number of rows in the file to be l
Conditional Judgment of Bash programmingBash Programming condition judgment: determine if the prerequisites for subsequent operations are met 1. The common judgment type of condition judgment (bash endogenous):Integer testCharacter testFile test2. Echo $? (Execution status return value): 0: correct 1-255: Error br> True or false 3, logical operation: True false = False (not 0)
Bash shell Script Introduction Shell Runtime EnvironmentIf you're running a Unix or Linux system, such as Ubuntu,red Hat,suse Linux and MacOS, it's built-in bash shell, so you don't need to configure the so-called development environment.My shell environment is the MacOS Sierra version, and if you're using a different Linux system, the following examples are basically operational.First, open the terminal co
When writing a shell program, you often need to handle command-line arguments, and this article describes the command-line approach under bash.Options and Parameters:Like the following command line:
Copy Code code as follows:
./test.sh-f Config.conf-v--prefix=/home
-F is an option, it requires a parameter, that is, config.conf,-V is also an option, but it does not require parameters.
--prefix We call it a long option, the option itself is more than one character, it also requir
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.