Replacing a row record in a property file with a shell script
Hypothetical as subordinate file Demo.properties
User.name=test
user.password=123456
...............................
Requirements: First you need to replace the value values of
Question: For string output such as ' 1,2,3,4,5 ', separate 1 2 3 4 5
Feature: no spaces in string
Workaround 1:
#!/bin/bash
var= ' 1,2,3,4,5 '
var=${var//,/} #这里是将var中的, replace with space for
element in $var
do
echo $ Element done
if else and greater than, less than, equal to logical expressionIf ...; Then
....
Elif ...; Then
....
Else
....
fi [F "somefile"]: judge whether it is a file
[-X "/bin/ls"]: Determine if/bin/ls exists and has executable permissions
[-N ' $var]:
When writing scripts in Linux, there is always the need to determine whether the existence of files, the contents of the file is empty and so on, and these operations can be implemented with the test instructions, through the man test instructions
It's easier to turn on the internet than to use awk.
Given two files a.txt and b.txt, each row is a record (assuming there are no duplicates), the intersection of two sets is required, the set of sets, the difference set, and the output results
1. String judgment
STR1 = str2 When two strings have the same content, the length is true
STR1!= str2 is true when strings str1 and str2 are unequal
-N str1 True when the length of the string is greater than 0 (string not empty)
-Z str1 True when
#!/bin/sh
Echo-n "Welcome to I programming World"
Echo-n "This program is a calculator"
Operator= "+-x/exit"
echo "Please input two digits:"
Read Number1 number2
Select I in $operator
Todo
Case $i in
+)
result=$ (($number 1+ $number 2))
Recently in doing the server, because it is all-weather operation, the server is not said to be absolutely stable, never crash never crashed anything, so even if the downtime does not matter, the key is to be able to start in time, can not affect
[Zxw@host1 ~]$ nl shscp/dump_backup_my.sh1 #!/bin/bash2 #dump MySQL data once per day, the reserve last 7 days data.3 #zhao Xiaowei4 #2014.08.275 Path=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:~/bin6 Export PATH7 dir=
Step One:
Locate the session information for the specified user, and draw up the execution script:
#!/bin/ksh
echo "conn Sys/sys as SYSDBA
select ' Alter system kill session ' ' | | Sid | | | serial# | | | ' From sys.gv\ $session where
The 1.expr command is generally used for integer values in the general format:
Expr argument operator argument
The general usage is to do arithmetic operations using expr, such as:
[Root@centos ~]# expr 10 + 20
30
$expr 30/3/2
5
(Note that operators
Let's take a look at some of the basic operations commands of the HBase shell, and I've listed several common hbase shell commands, as follows:
Name
Command-expression
Create a table
Create ' table name ', ' column
first, built-in variables
1. $BASH
The path to the bash's binary program file (the path to the script interpreter)
$ vim test.sh
Enter the code:
#!/bin/bash
Echo $BASH
To run the code:
$ bash test.sh
2. $FUNCNAME
The name of the current
Enterprise Practice question 1: (Production actual case): monitor MySQL master-slave synchronization is abnormal, if abnormal, send sms or mail to the administrator. Note: If there is no master-slave synchronization environment, you can use the
1. Sometimes operation and maintenance requirements automatically generated Cronab task scheduling, the implementation of the corresponding service name management; #!/bin/bash#athor check crontab crontab_ Add () {cron_path= "$" cat >/etc/cron.d/$
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
Shell script:
A text file that contains some commands or declarations and conforms to a certain format
Format requirements: First line shebang mechanism
#!/bin/bash
#!/usr/bin/python
#!/usr/bin/perl
The
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