Vim editor and shell script command
Vim text editor
pdf version
1, three operating modes
2, vim commonly used in command mode command
3, line mode commands available
4, write simple documents
(1) Configuration Host Name
vim /etc/hostname
(2) Configuration card information
(3) Configuration Yum repositories
5, simple scripting
1, a simple scripting files
vim examlpe.sh
Generally .sh script file suffix to indicate a script file.
#!/bin/bash
#For Example By linuxprobe.com
pwd
ls -al
! # The first line statement uses the bash interpreter to execute the script;
The second line of the script function.
Followed linux command execution.
2, the user is accepted parameters
Script file is to use the file name, followed by the parameter. Such as:
#example.sh
#!/bin/bash
#For Example By linuxprobe.com
echo "filename: $0"
echo "param one: $1"
echo "param two: $2"
echo "param three: $3"
#terminal执行
bash example.sh 1 2 yang
result:
filename: example.sh #$0代表第一个参数,是文件名
param one: 1 #$1是实际上的第一个参数
param two: 2
param three: yang
3, the user determines the parameter
(1) Test conditions for statements
#条件测试格式
[ 条件表达式 ]
(2) test parameter file
(3) an integer comparison operators
(4) determination logic
&&: that will execute the command after the current command behind the surface of the executed successfully.
||: Indicates the current command fails will face after the implementation of subsequent commands.
!: The results of the test paper determination condition negated value.
(5) String comparison
Flow control statements
1, if the test condition statement
(1) Single branched structure
if 条件测试操作
then 命令序列
fi
(2) a branched structure bis
if 条件测试操作
then 命令序列1
else 命令序列2
fi
(3) Multi-branched structure
if 条件测试操作1
then 命令序列1
elif 条件测试操作2
then 命令序列2
else
命令系列3
if
2, for loop condition
for 变量名 in 取值列表
do
命令系列
done
3, while condition loop
(1) syntax
while 条件测试条件
do
命令序列
done
4, case statements test conditions
(1) Format
case 变量值 in
模式一)
命令序列1
;;
......
*)
默认命令序列
esac
Scheduled Tasks service program
1, a one-time task execution plans only once:
Steps:
(1) at time
(2) at -l: View set up a one-time program, but the task has not been executed.
(3) atrm task Number: delete it.
2. Operation:
3, create periodic, perform certain specific tasks regularly:
(1) crontab -e: Edit create a scheduled task
(2) crontab -l: View command scheduled tasks.
(3) crontab -r: delete a command bar program.
Parameters order:
(4) If the command statement crond services need to include a number of scheduled tasks, should each write a line only; in crond service, all commands must use an absolute path way to write.