Tag:expr bsp Command not csharp other filename line awk Shell Learning notemain= "/usr/local/" # Variable uppercase status= "$MAIN/status" # USD multibyte string is a reference variable value, while USD multibyte number
Change the previous code1. Infer if it is hello, assuming yes. It shows "Hello, how is it?" ;2. Assume that no number of parameters is added or not. To prompt the user must use the method of the number of instructions;3. Assuming that the increased
(1)Monitoring 80 Ports Write a script to determine whether the 80 port of the machine is open, if you do not do anything, if you find that the port does not exist, then restart the httpd service, the concurrent mail notify yourself. Once the script
Use the time of the Linux system in the second 1-59 to guess the number game, the detailed code is as follows:#!/bin/bash#author wangning#date 2017-7-15#qq 1198143315#email [email protected]##### ############################## #define color#########
Functions are often used when writing programs, and general development tools have a rich library of functions. But sometimes you need to customize the function to meet our needs.In Linux, the same is true for shell scripts, which sometimes use
5.3 Shell Programming 2Condition Judgment:If the user does not existAdd user, give password and show add successOtherwiseDisplays if it already exists, does not addHow do I make conditional judgments in bash?Condition Test Type:Integer testCharacter
Data flow redirection is the transfer of a command that should appear on the screen to other places after executionStandard1, standard input (stdin): code 0, using or 2, standard output (stdout): Code is 1. , using > or >>3, standard error output
Open a text editor (you can use the Vi/vim command to create a file), a new file test.sh, the extension sh (sh for Shell), the extension does not affect the execution of the script, see the name is good, if you write Shell script in PHP, the
First name the shell command as a. sh fileSave the above code as test.sh. and CD to the corresponding folder:chmod +x./test.sh #使脚本具有运行权限./test.sh #运行脚本Assuming an error/bin/bash^m:bad interpreter:no such file or directoryOne of the reasons for
Problem: Now there are two scripts, I want to match the contents of File1 by File2[email protected] home]# cat file13-1-1 potv=1,pota=0,potp=21-4-76 potv=1,pota=0,potp=12-1-2 potv=1,pota=1,potp= 13-1-4 potv=1,pota=1,potp=24-1-5 potv=1,pota=1,potp=27-
Parameter unwinding (parameter expansion) is the procedure that the shell uses to provide variable values in a program.Expansion operators include substitution operators and pattern matching operatorsSubstitution operators
Operator
Reading slow, easy to forget, on the Internet to find examples to do, pondering the examples do not understand, and then continue to Baidu.The importance of shell scripts under Linux is not much to say. Starting with the first example:#!/bin/"Hello
In general, most shell command windows, such as Python,scala, some non-relational database, and so on can be ctrl+d or ctrl+z,ctrl+c exit, this is the most effective way.If you do not use the above mandatory exit command, you can also use quit,exit,
Tag: Folder file exists and dir file directory parameter is judged#shell判断文件夹是否存在 # If the folder does not exist, create a folder if [!-D "/myfolder"]; Then Mkdir/myfolderfi#shell determine the file, whether the directory exists or has permissions
The Shell implements a simple calculator function with the following script:[[email protected] scripts]# Cat Jisuan.sh#!/bin/bashprint_usage () {printf $ "usage:$0 NUM1 {+|-|*|/} num2\n" Exit 1} #判断传入的参数是不是3个if [$#-ne 3] then print_usagefifirstnum=$1
String slices:${var:offset:number}Offset: The number of strings to skipNumber: The string to be fetchedCases:Name= "Obama"${name:1:2}--Displays the result as Ba${name:1}--Displays the result as BamaTake the rightmost few characters of the string:
Method:
Kill–9 ' pgrep Java '
Use the above command to kill all Java processes running on the server at once.
Extension: The role of child shells and anti-application in shell scriptsLet's look at an example of a child shell:# Cat
Ifs:A direct description of the usefulness of IFS, details of what ifs is doing ... Self GoogleFirst create a file of "a", and "a":Then we look at LS:--LSA a AIs this.Then if we need to write a script to manipulate each file:--For I in $ (LS); Do
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service