Hello everyone! Today's share is the basic knowledge of some shell scripts, chapter for the introduction of the content of this article are: variables (classification, assignment, query, reference), arithmetic operation implementation.Introduction
1. Regular expressions
^
Line Start flag
$
End of line Mark
.
Match any one character
[ ]
Match any one of the characterscontained in [ character ] ,Coo[kl] matches Cook or
First, what is the bean Shell
BeanShell is a scripting language that conforms fully to the Java syntax specification and has its own syntax and methods.
BeanShell is a loosely typed scripting language (this is similar to JS);
in general, there are three parts, each of which are: character class , quantifier, position qualifier. Specifies that some special syntax denotes character class, numberVolume qualifiers and positional relationships, and then use these special
1. Time CalculationStarttime= 'Date+'%y-%m-%d%h:%m:%s''; Endtime=`Date+'%y-%m-%d%h:%m:%s''; Start_seconds=$(Date--Date="$starttime"+%s); End_seconds=$(Date--Date="$endtime"+%s);EchoEnd_seconds-start_seconds2. Get the status code returned by the
Command editing ability (history):One of the great features of Bash is that "he can remember the commands he used!""This is a really great feature!" Because I just have to press the "up and Down" button in the command line to find the front/rear
Shell Script whitespace specificationPractice, write a script:Pass a user name parameter to the script to determine if the user's user name matches the group name of their base group, and displays the results#!/bin/bash#if! ID $ &>/dev/null;thenecho
Linux kernel is responsible for driving hardware, management activities and allocation/management of hardware resources and so on, so that the system to check the normal operation of the computer is really too important, so it is generally not
[ -a FILE ]
FILEtrue if it exists.
[ -b FILE ]
True if it FILE exists and is a block special file.
[ -c FILE ]
FILEtrue if a special file is present and is a word.
[ -d FILE ]
True if it
Order of 1.Shell Search commandsWhen the shell executes the command, it does not directly look in the path path, but instead looks for the command location in a fixed order. The search order is as follows.1. Aliases. Even if you create a command
Syntax 1:substring=${string:start:len}The subscript of string starts with 0, with start, but the Len character is truncated and assigned to substring1 #!/bin/bash2 #substr =${string: Start:len}3 str=" 123456789 " 4 substr=${str:3:3}5echo $substr6 7
The fourth chapter is about the shell variable knowledge advanced and practice;The fifth chapter is about the numerical calculation practice of variables;The annex includes the source code, please download.The two chapters should pay attention to
Format: Date [options] ... [+ format]Option Description:-D,--date= string displays the time described by the specified stringFormat Description:Example 1:#!/bin/bash##1. Gets the current system time yyyy-mm-DD HH:MM:SSv_time_eq=`Date "+%f%T"'
Command history# Cat/root/.bash_history//place where historical commands are stored# History//View the number of command histories# echo $HISTSIZE//View the number of bars that can be saved# Vim/etc/profile//Change the value of variable histsize
1. Write more comments in the script This is a recommended practice that can be applied not only in shell scripts, but also in all other types of programming. commenting in a script can help you or others to read your script
Shell script variable What is a variableReplace another complex or volatile data with a simple "word"Display and setting of variables: The display of Echo,unset variables Echo ${path}Setting rules for variablesequal sign Connection variable =
variable names can only contain numbers, letters, and underscores, because some variables that contain other characters have special meanings, and such variables are called special variables.
List of special variables
Background: Documenting the process of deploying a JAR program in a Linux environment1 Deployment Process record 1.1 program structureThe main function here is in the Demrest2.java file.For ease of deployment, do the following two points:1 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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service