A simple calculator implemented with a shell

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

Shell string Matching

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

The \ r character in the shell script.

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

Arithmetic operations in the shell

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:

Linux Shell Script Example (iv)

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

Shell scan on the same network segment surviving host

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

Shell Scripting Exercise A

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 "

Shell Scripting for backup, publish, rollback by directory

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

exec parsing in Shell under Linux

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

Shell Kill Tomcat Process

First, killandclean.sh#!/bin/bashpid= ($ (ps-ef | grep tomcat | egrep-v grep | awk ' {print $} ')) length=${#pid [*]}if [$length-gt 0] thenfor i in $pid does ' kill-9 $i ' done with echo ' kill over ... '

Links between Makefile,shell Command,shell Language

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

Shell Script Detection Service

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

Shell Exercise 1 Writing shell conditional sentence exercises

Instance one, compare two integer sizes#!/bin/Bash while true DoRead-P"Please input the int nums:"a BExpr$a + $b +0>/dev/NULL 2>&1 #判断是否为整数 if[$?-eq0];Then #返回值是否为0 if[$a-gt $b]; Then Echo "$a > $b"Exit0 elif[$a-lt $b];

Shell script Linux Commands execute continuously

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

Shell script----for loop

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

Shell quotes those things

#通配符 {} * []?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

Shell Basic Introduction and case

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

Examples of Linux shell processes

#!/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 relationship

linux-Shell core and shell relationshipThe kernel is in the shell, interacting with the shell (command line) through the shell#####################################################################################################Shell Viewwhich $SHELL/

The most value of the room function of the shell of garlic (good question, clever sort)

Title Link: https://nanti.jisuanke.com/t/27644Main topic:Problem Solving Ideas:Code:1#include 2 #defineLC (a) (a3 #defineRC (A) (a4 #defineMID (A, B) ((A+B) >>1)5 #defineFin (name) freopen (name, "R", stdin)6 #defineFout (name) freopen (name, "W",

Total Pages: 541 1 .... 397 398 399 400 401 .... 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.