#!/bin/bash#echo "1.$12.$23.$3"If ["$" = "+"]ThenRes= ' expr $ + $ 'echo ">>the result is: $RES"elif ["$" = "-"]ThenRes= ' expr $-$ 'echo ">>the result is: $RES"
#这里说明下, using "x" instead of "*"
#是因为在命令行输入 *,shell parsing problem,
#* cannot be
Question: How does the shell judge a filename to start with a character ~
Solve:
#var = "cn get the length of me"
#$1:parameter 1 to judge the name of the file
Var=$1
Iscn=false
# ${var:0:2} takes the Var substring from the No. 0 character and
On Windows with notepadd++ edit a shell script, die or die, back to Linux, edit, or have this \ r, search the next, is this:
http://bluemood.blog.51cto.com/1142811/1030925
‘
because the shell processed the character file in Windows, the string
There are many kinds of arithmetic operations in the shell, such as a=1,b=2, so how to calculate the value of A+b? Can not simply $a+ $B, if this operation, the result is 1+2, obviously not the result we want, the result is 3, we have a few methods:
Example No. 2As a shell writer, often face the problem of inconsistent data format, the data standard session output is a need to solve the problem, this example takes MySQL time as an example, the script enters the month, the day, the year three
This example takes the class C address as an example, if it is a Class A or class B address, the script can be modified slightlyIpaddr= '/usr/sbin/ip a | grep $1 | grep inet | awk ' {print $2} ' netmask= ' echo ${ipaddr} | awk -f '/' ' {print $2
ifMulti-branch statement practice#!/bin/bashread-p " Please enter 100 m running seconds: "IIf [$i-lt] && [$i-GT 0]Thenecho " Enter the final "read-p " enter male and female "aif [$a = male]Thenecho " into the men's group "elif [$a = female]Thenecho "
Share a recently written shell script that enables you to back up the production line files and rollback operations by the file directory structure of the published package.1#!/bin/SH2Path="/home/www/site1"3pub= $path"/release/pub/mboxii/trunk"#发布目录4
Both exec and source belong to the Bash Internal command (builtins commands), where you can view all the internal command information by entering man exec or man source under bash.The bash shell commands are divided into two categories: external
1. MakefileThe first thing to know is what Makefile is, Makefile is a directive file, which stores custom commands (which can be created with the help of existing commands), and differs from Makefile in different systems, linux/ In UNIX systems, the
Lab Environment:System: centos7-3.10.0-x86_64Testing Services: apache-tomcat-9.0.7Experimental reasons:Because the current environment for the Java test environment, so did not monitor, but recently found that the service is automatically down, and
Three ways the shell command executes continuously:1, command 1; command 2; command 3Executes the command sequentially, regardless of whether the previous command executed successfully.2. Command 1 && Command 2 && command 3The next command is not
1. Method 1[CPP]View PlainCopy
#!/bin/bash
For ((i=1;i
Do
Echo $i
Done
Save As For1.shDirect SH for1.shWill error:The Syntax Error:bad for loop variable workaround code is not a mistake for standard bash, because
#通配符 {} * []?1.1 The difference between quotation marks and unquoted 1:[[email protected] ~]# touch a B[email protected] ~]# LLTotal 0-rw-r--r--. 1 root root 0 June 16:25 a-rw-r--r--. 1 root root 0 June 16:25 b[[email protected] ~]# touch "a
First, Shell Script Foundation1. First ScriptVim first.shThere are three ways to execute scripts, respectively:./first.sh (need to have executable permissions)SH first.sh . first.sh(or source first.sh)2. Redirects and Pipe breaks1) redirected
#!/bin/bashRead-p "Input a dight:"Echo $REPLYDate= ' Date 'echo "DATE is ${date}"Users= ' Who |wc-l 'echo "LOGIN in User is ${users}"up= ' Date;uptime 'echo "Uptime is ${up}"#echo "HELLO world!"#echo "What's Your Name"#read person#echo "HELLO
linux-Shell core and shell relationshipThe kernel is in the shell, interacting with the shell (command line) through the shell#####################################################################################################Shell Viewwhich $SHELL/
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