Linux basics-Bash command priority, linux-bash priority
1. Bash Introduction
The command interpreter, also known as the Bourne Again Shell, originated from the shell. Shell, commonly known as shell, refers to a command parser in a UNIX system. It is mainly used for user-system interaction. There are many types of shells on UNIX systems. The first shell, namely, t
Job Management in Bash and bash job Management
I was not prepared to write this blog, because Task Management (job Management) is very common, so I feel that there is no need to write such a thing. But if you think about it, record it. Maybe someone will use it.
I wonder if you have ever encountered such a situation. When you are eager to open VIM and write code to the right corner, the operating MM or prod
Linux Command: bash language details, linux Command bash details
Bash is a command interpretation language. It can execute commands that read standard input or files, execute commands, and rebound shell with nc!
Basic syntax
Bash-c command
Root @ kali :~ # Bash-c whoami
Learning bash notes-input and output, bash hide output1. I/O redirection
The I/O redirection is as follows:
Cmd1 | cmd2: pipeline that receives the standard output of cmd1 as the standard input of cmd2.
> File: redirects standard output to file.
> File: redirects the standard output to file. If the file exists, it is appended
> | File: Even if noclobber is set, the standard output is still fo
Bash Variable type:Environment variablesLocal variables (local variables)Positional variablesSpecial variablesLocal variables:Set Varname=value: scope for the entire bash process;Local variables:Local Varname=value: Scope is the current code snippet;Environment variable: The scope is the current shell process and its child processes, (the action variable itself uses VARNAME, the value of the action variable
Bash concise tutorial -- variables, bash concise tutorial Variables
1. Preface
Bash is a popular scripting language in * nix systems. As a scripting language, variables are the basic elements of a language. In this tutorial, we will learn how variables are represented in Bash and some syntax rules related to variables.
Bash condition test-empty string confusions: bash condition string
You can use-n or-z to check whether a string is null. According to the meaning of the operator, if VAR is null or undefined, the-n test result should be false, and-z should be true. Otherwise,-n is true and-z is false.
The conditional test list is used, that is, "[-n $ VAR] echo TRUE". If TRUE is output, the conditional test result is TRUE.
In our work, we often need to replace and add URLs from the text using SED. However, we often encounter the ambiguity in the SED of special characters in the URL so that it takes a lot of time to test when writing a bash script. So what are the special characters that create ambiguity?
#这些都需要转义, |, \,/, ^, *, (,), [,], {,}, ',?
Which, to ",/,?" " for the most important needs to transfer. For example:[Email protected] test]$ url="HTTP://
One:The shell is the shell of the Linux/unix system, and it can be understood as the command line interface, where you enter and execute the command line.Bash (born again shell) is one of the shell's most commonly used shells. you run on your Linux: PS | grep $$; If you run the result as bash, it means that the current default shell is bash.The shell is basically a command interpreter, similar to the commands under DOS. It receives user commands (such
; Alertalias alert= ' Notify-send--urgency=low-i "$ ([$? = 0] echo Terminal | | echo error) "" $ (history|tail-n1|sed-e ' s/^\s*[0-9]\+\s*//;s/[;| ") \s*alert$//' \ ') ' # Alias definitions.# want to put all your additions into a separate file like# ~/.bash_aliases, instead of adding them here directly.# see/usr/share/doc/bash-doc/examples In the Bash-doc Package.if [-f ~/.bash_aliases]; Then. ~/.bash_alia
Fun Bash Script: numerical calculation, bash script Numerical Calculation
6th articles
The mathematical operations in Bash are not as simple as other languages, because Bash treats all variables as strings, so a = 1 + 2, a is not equal to 3, but equal to string 1 + 2.
There are several solutions to solve this problem.
Bash usage summary, bash usageIn Linux, shell is basically bash by default. Below are some tips I have summarized. Background running programs() Use a sub-shell, such as (cd.../../commlib/; make)$ () Command replacement, same''Example:For example, you need to use the awk script in the shell script.Awk-f /Abc /{Print $0;}EOF)
$ () Perform integer calculation $(66
host.Usage:4Fc–lReadPurpose: Reads a row of data from a standard input.Usage: Read variableCase:Echo ' Please enter your English name? ‘Read ynameEcho ' Your name is: '$ynameIf you do not specify a variable to receive data after the read, the default variable name is replyEcho ' Please enter your English name? ‘ReadEcho ' Your name is: '$REPLYThe same can be achieved by using the READ–P approach:Read–p ' Please enter your English name? ‘Echo ' Your name is: '$REPLYOption-P refers to the meaning
SHELL script strategy (learning notes) -- 1.5 bash environment configuration process, -- 1.5 bash
From the perspective of user login, shell is divided into two types:
Logon shell: If you log on through a terminal, use the su-username command to switch users.
Non-interactive shell: for example, you can use the su username command to switch between users. Open the command terminal and shell script in the grap
Fun Bash Script: select the structure of if, bash script
Almost all programming languages have the concept of process control, that is, order structure, selection structure and loop structure.
The selected structure is also called the branch structure, such asIfAndSwitchStatement.If condition
I have already discussed the use of the test Expression and Its Simplified [] Operator. These judgment statements ca
command line. For example, if alias mywork = 'CD/home/Wei/project/mywork' is embedded in mywork, you can directly enter the specified command, however, we cannot alias mywork =/home/Wei/project/mywork, and then CD mywork. aliases will not parse commands that do not come first. In this case, you can use the export method.
Alias: for example, the current alias list
AliasName
: For example, the true meaning of name
UnaliasName
: Unbind the alias of this name
Option
We can useSet-oOption
Bash variable types and bash Variables
Local variable: it acts on the Current shell and is invalid for other shell processes other than the current shell and the Current shell Sub-processes.
Assign a value to a local variable
name='value'
Value can be a string or a variable. The referenced variable uses $ {name}, $ name, or ''.
Note: single quotes are strongly referenced, while double quotes are weak refere
In the process of reading any questions, welcome to communicate togetherEmail:[email protected]qq:1494713801when executing a script full_build.sh, I was always prompted :-bash:./full_build.sh:/bin/bash^m:bad interpreter:no such file or directoryOr remind syntax error:unexpected end of FileOne of the reasons for the above error is that the script file is in DOS format, that is, the line end of each line is i
case.The other 3 conf files are * not * read again.
After doing the above changes, its time to move on to some more "hardening ".One more step towards (futile) protection.
// Step 2 //
-- Configure. bash * configuration files
All changes will be made to. bashrc. It is assumed the other threeConfiguration files mention reading. bashrc in their body. This means that. Bashrc is read in * every * case (whether the user just logins or invokes a newBash sh
This article is also the second of the book note in Chapter 4 Basic shell programming of learning the bash shell 3rd edition, but we will not limit it to this.
String operation
In the following description, ":" Can be deleted. "Yes" means "exist but cannot be null". ":" means "exist ", this parameter can be left blank:
$ {
Varname
:-
Word
}
: If varname exists and is not null, the value of varname is returned; otherwise, word is returned. Returns a
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.