1.12 Functions and Parameters
Like other scripting languages, Bash also supports functions and can pass parameters.
1.12.1 function definition and parameter transfer#!/bin/bash function fname () #也可以用fname () instead of {echo $1 , $
ShellThe shell is a weakly typed programming language.Distinction between strong and weak:Strong: Variables must be declared prior to use, and even require initialWeak: Variables are declared when they are used, even the part is differentiated by
Special variables: $#the number of arguments passed to the script; $*displays all parameters passed to the script in a single string. Unlike positional variables, this option can have more than 9 parameters; $$the current process
1. Check the current system who is logged in: Who2. Count the logged-in users of the current system: who | Wc-l (L-->line,w-->word,c-->character)3. Small shell script development cycle: $cat > Nusere new file, using Cat copy terminal inputW.H.O. |
The first step:SSH Password-free login "with public key, private key"Step Two:#!/bin/bash while read server; Do "[email protected]" 2 >& 1 "s/^/$ Server:/" &donewait./bunsan2.sh Free Note: While read server considers the input as a
1, log structure/opt/online/{123com,abccom}/log/online[1-9]/[a-z]2, variable description # Whether to turn on the compression function (0: OFF, 1: on; If the compression function is turned off, the Compressdayn is not valid) Needcompress=1 Delete 14
1. CommentsIf you use bash, then in the script file header comment: #/bin/bash2, the script file with the Read and execute permissions, you can use the./shell.sh to execute, you can also use the SH shell.sh way to execute directly, SH is the soft
When we are learning some frameworks, we usually invoke a script when we start the framework, and pass some parameters to the script, and the script will do different things depending on the parameters we pass, and the parameters we pass are the
Remember this is the original play Cdlinux when, originally should be because of windows under the UltraISO to Cdlinux mirror changes cause the image can not boot, so use the command under Linux to operateThis should be the command to mount the ISO
1. ValueFormat:Test "NUM1" OPR "num2"["Num1" OPR "num2"]OPR Value:Equality:-EQUnequal:-neGreater than:-GTLess than:-lt "L is the lowercase letter L"Less than equals:-leGreater than or equal to:-ge2. StringFormat:[Str1 OPR str2][OPR str]OPR
Installing ClustershellInstall from https://github.com/cea-hpc/clustershell/downloads below source or binary package. The following is an example of CentOS6.6 using RPM installation: wget
Check if the remote port is open for bash:
NC-nvv $IP $PORTtelnet $IP $PORT
Front and back switch for current task:
Ctrl + ZFG
The first 5 characters of the Intercept variable:
${variable:0:5}
SSH Debug
Regular expressions in the shellVbird said that learning Linux, mastering the shell and the regular is equivalent to open the two-channel, after the ability of the growth will be rapid.The Shell's basic learning has been summed up in a blog post:
Default variable for Shell script ($ ...)We know that directives can have options and parameters, such as Ls-la to see all properties and permissions that contain hidden files. So can shell script have parameters behind the script file name? It's
Sed is a good file processing tool, itself is a pipe command, mainly in the behavior of the unit processing, you can replace the data rows, delete, add, select and other specific work, the following first understand the use of SEDThe SED command
Linux learning-advanced shell script programming (2) first recognized by sed, gawk, and sedgawk
Citation: Sometimes we need to automatically process text in text files without pulling out a fully armed interactive text editor. In this case, it is
Linux learning-advanced shell script programming (I) Functions and shell script Programming
Citation:When writing shell scripts, you will find that the same code or functions are used in many places. It doesn't matter if it's a small piece of code.
Shell-based variablesVariable typeShell variables include environment variables, location variables, pre-defined variables, and custom variables.Environment VariableShell environment variables are a type of Shell predefined variables used to set the
Several methods of shell script executionYou can execute shell scripts in the following ways:
1. The relative path method must be cd to the script path first.
[Root @ banking tmp] # cd/tmp [root @ banking tmp] #./ceshi. sh script executed
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.