Use of read in the shell

read [parameter] [variable name]Read-p "Please input a number:" VarRead-t 10-p "Please input a number:" Var#!/bin/shWhile TrueDoRead-t 10-p "Please input number:" A BExpr $a + 0 >/dev/null 2>&1[$?-ne 0] && continueExpr $b + 0 >/dev/null 2>&1[$?-ne 0]

Shell Learning Note

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

Shell Scripts-Conditional statements, case statements, function functions

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

Shell Exercises (2)

(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

Shell script Implementation empties log

#!bin/bashLog_dir=/var/logRoot_uid=0if[' $UID '-ne ' $ROOT _uid ']ThenEcho ' must is root to run this srcripts 'Exit 1FiCD $Log_dir | | {echo "Cannot change Necessarydirectroy" >&2Exit 1}Cat/dev/null >messages&&Echo ' log is cleaned up. 'Exit 0 #返回0

Guessing a digital shell script in Linux

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#########

How shell scripts Customize functions

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

Learning note -5.3 Shell Programming 2

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

shell--Data Flow Redirection

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

Shell--1, first shell script

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

Run the shell command

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

Match shell variable characters in awk

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-

Shell parameter expansion

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

Shell Simple Introduction (i)

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

The Scala shell window is out of the way.

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,

Shell determines whether a file or folder exists

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

Shell Implements simple calculator function

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

Shell string Handling

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:

Bulk Kill Java Process Method-elicit child shell and dereference

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

A summary of several cold knowledge of the shell (IFS, arrays, substitutions, splits, lookups)

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

Total Pages: 541 1 .... 374 375 376 377 378 .... 541 Go to: GO

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.