script standard:
腳本代碼開頭約定
1,第一行一般為調用使用的語言 2,程序名,避免更改文件名為無法找到正確的文件 3,版本號 4,更改后的時間 5,作者的相關信息 6,該程序的作用,及注意事項 7,最后是個本版的跟新簡要說明
shell script list:
#!/bin/bash #------------------------------------------------ #Filename: mysql.sh #Revision: 1.0 #Date: 2019/11/06 #Author: David #Email: dm_98K@163.com #Website: www.dengmeng.vip #Description:This is the install mysql5.7 script #------------------------------------------------- #Copyright: 2019 David #License: GPL echo "hello world" ###變量關鍵地方設置為紅色 r1="\033[1;31m" n1="\033[0m"
Create the format of the script:
#!/bin/bash cat > $1 <<EOF #!/bin/bash #------------------------------------------------ #Filename: $1 #Revision: 1.0 #Date: `date +%F` #Author: David #Email: dm_98K@163.com #Website: www.dengmeng.vip #Description:This is the $2 script #------------------------------------------------- #Copyright: `date +%Y` David #License: GPL" EOF chmod +x $1 vim + $1