linux,shell2015-02-07 1. Scheduled tasks: Corntab-e writing Scheduled Tasks  CORNTAB-L viewing Scheduled tasks Corntab-r Clear all Scheduled Tasks If you want to clear a scheduled task, you can go to the edit page of the scheduled task, and delete it individually to 2. Task Scheduler Authoring and execution content: Format: Time-of-year command [[email Protected] cpre]# */5 * * * * command #每隔5分钟执行一次 [[email& Nbsp;protected] cpre]# * * 20 command #每周2到周日的9点执行一次命令 & Nbsp; [[email protected] cpre]# 00 * * 2,3,4 command #每个周2, 3,4 9-point execution once command anti-quote function under 3.linux Date= ' Date ' +%y-%m-%d ' #反引号, which means that the command inside the inverted quotation marks is executed as a single individual and then assigned a value tar czf web-${date}.tar.gz web # $ number output format & nbsp 4.shell variable types and applications a. Case sensitivity cannot start with a number  B. Format: Variable name = variable value #变量提高代码灵活度 (* * There is no space between instructions for variable assignment in Linux) & nbsp; c Output variables echo "Output content" name= ' Liangi ' echo $name echo "My Name is ${name}" #注意 $ sign use & nbsp d. Assigning values to variables input assignment: read-p "please inout Your name: " name #将输入的值赋值给name echo $name E. Different quotes are variable assignments (both single and double quotes cannot refer to transfer characters) double quotes "": Parse variables, that is, time-varying quantities inside double quotes & nbsp; single quote ': cannot parse variable, The variables inside cannot be resolved Anti-quote ': Execute the command in the counter-quotes and assign the value f. Delete variables unset name Defining variables after they are used, delete the variablesIn addition to unset, you can re-assign values 2015-02-081. Position variables Positional variables are the number of positional variables defined in the script first, and at the time of execution is the #./loca.sh 1 SD d f h Then in the next output The location variable 2 that you defined is displayed. Pre-defined variables Paste All the note notes you made when learning the predefined variables--start-- #!/bin/bash
#预定义变量测试与学习
#这个程序调试了很久, the main reason for the error is to write the program careless error, there is the question of space, shell space is very fastidious, like in the Terminal Input command. Therefore, when writing the Linux-shell script > when it is in the terminal to enter the Linux command, pay attention to the format, with a Linux input command in the heart to write Linux script
echo $ #, display the name of the current script echo "Your current script name is: $"
Echo $# #获取所有参数个数
Echo ' I'm a singer '
Echo $* #列出变量是什么
Ls
echo $? #回馈上一条命令是否执行正确, Normal, returns 0
Total=0
For i in $*; Do
total=$ (($total + $i)) #将每个预定义变量相加, predefined variables must be numbers to add
Echo $total
Done
Echo $total
if [[$ = = 0]]; Then
Echo ' previous command execution succeeded '
Else
Echo ' Last command execution unsuccessful '
The problem program is marked with the fi #
~ --end--3.shell script Operations expr + 30 #空格要注意 number= ' expr 20 + 30/ 2 ' #引用命令结果需要加上反引号 echo $ ((2 + 3 +4)) 4. Shell script input and output ECHO-E "SJDK \ n ds" #-e resolve output Reference transfer characters echo-n "DSJK" #执行完该命令之后, the cursor does not wrap with: Read-p "please Input Your Name: "name echo $name echo #直接输出的是空行 Script output font Color-(requires ECHO-E to recognize) grammar ECHO-E "\033[32;40m[ok ]\033[0m " \033[foreground color; background color m \033[0m #0m代表恢复到系统配色方案 code to write all Color: 30-37 stands for foreground color black green brown blue Violet plainer 40-47 for background color black green brown blue Violet plainer 5. Cat view C at<<x AAAA&NBsp; x #将任意字符xx里面的原样输出-can be used to make menus head view top 10 lines head-2 view top 2 lines & nbsp; tail View after 10 lines TAIL-2 view after 2 lines Tee output one copy, also save a copy of ./te.sh | te.txt #保存在当前目录 NL Mark Travel number in front of output text
Learning shell Script journaling