当前位置: 首页 > news >正文

镇海住房和建设交通局网站怎样免费建公司网站

镇海住房和建设交通局网站,怎样免费建公司网站,营销策划案例,wordpress安全教程9.Scripts9.1什么是 Shell scriptsshell script 是利用 shell 的功能所写的一个『程序 (program)』#xff0c;这个程序是使用纯文本文件#xff0c;将一些 shell 的语法与指令(含外部指令)写在里面#xff0c;搭配正规表示法、管线命令与数据流重导向等功能#xff0c;以达…9.Scripts9.1什么是 Shell scriptsshell script 是利用 shell 的功能所写的一个『程序 (program)』这个程序是使用纯文本文件将一些 shell 的语法与指令(含外部指令)写在里面搭配正规表示法、管线命令与数据流重导向等功能以达到我们所想要的处理目的。9.1.1干嘛学习 shell scriptsl自动化管理的重要依据l追踪与管理系统的重要工作l简单***检测功能l连续指令单一化l简易的数据处理9.1.2第一支 script 的撰写与执行在 shell script 的撰写中还需要用到底下的注意事项l指令的执行是从上而下、从左而右的分析与执行l指令、选项与参数间的多个空白都会被忽略掉l空白行也将被忽略掉并且 [tab] 按键所推开的空白同样视为空格键l如果读取到一个 Enter 符号 (CR) 就尝试开始执行该行 (或该串) 命令l至于如果一行的内容太多则可以使用『 \[Enter] 』来延伸至下一行l『 # 』可做为批注任何加在 # 后面的资料将全部被视为批注文字而被忽略1.撰写第一支 script[rootlocalhost tmp]# vim hello.sh#编写脚本#!/bin/bash           #指定执行脚本的shell# Program:#       This program shows Hello World! in your screen.# History:# 2015/07/16 VBird First release       #  #开头的为注释PATH/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH          #定义PATH属个人习惯echo -e Hello World! \a \n       #输出hello worldexit 0         #设置脚本返回值[rootlocalhost tmp]# sh hello.sh#运行脚本Hello World!9.1.3撰写 shell script 的良好习惯建立建议一定要养成良好的 script 撰写习惯在每个 script 的文件头处记录好nscript 的功能nscript 的版本信息nscript 的作者与联络方式nscript 的版权宣告方式nscript 的 History (历史纪录)nscript 内较特殊的指令使用『绝对路径』的方式来下达nscript 运作时需要的环境变量预先宣告与设定。9.2简单的 shell script 练习9.2.1简单范例1.对谈式脚本变量内容由用户决定[rootlocalhost tmp]#vim showname.sh#!/bin/bashread -p Please input your first name: firstname      # 提示使用者输入read -p Please input your last name:  lastname       # 提示使用者输入echo -e \nYour full name is: ${firstname} ${lastname} # 结果由屏幕输出[rootlocalhost tmp]# sh  showname.shPlease input your first name:liuPlease input your last name:  huaYour full name is: liu hua2.随日期变化利用 date 进行档案的建立[rootlocalhost tmp]#  vim 1.sh#!/bin/bashecho -e I will use touch command to create 3 files. # 纯粹显示信息read -p Please input your filename: filename         # 提示使用者输入date1$(date --date2 days ago %Y%m%d)  # 前两天的日期date2$(date --date1 days ago %Y%m%d)  # 前一天的日期date3$(date %Y%m%d)                      # 今天的日期file1${filename}${date1}                  # 底下三行在配置文件名file2${filename}${date2}file3${filename}${date3}touch ${file1}                           # 底下三行在建立档案touch ${file2}touch ${file3}[rootlocalhost tmp]# sh 1.shI will use touch command to create 3 files.Please input your filename: file[rootlocalhost tmp]# ls1.sh  file20200425  file20200426  file20200427  hello.sh3.数值运算简单的加减乘除[rootlocalhost tmp]# vim 1.sh#!/bin/bashecho -e You SHOULD input 2 numbers, I will multiplying them! \nread -p first number:  firstnuread -p second number: secnutotal$((${firstnu}*${secnu}))echo -e \nThe result of ${firstnu} x ${secnu} is ${total}[rootlocalhost tmp]# sh 1.shYou SHOULD input 2 numbers, I will multiplying them!first number:  2second number: 3The result of 2 x 3 is 69.2.2 script的执行方式差异 (source, sh script, ./script)[rootlocalhost tmp]# cat showname.sh#!/bin/bashread -p Please input your first name: firstnameread -p Please input your last name:  lastnameecho -e Your full name is: ${firstname} ${lastname}1.相对路径执行[rootlocalhost tmp]# chmod ax showname.sh  #先增加执行权限[rootlocalhost tmp]# ./showname.sh    #相对路径执行Please input your first name: liuPlease input your last name:  huaYour full name is: liu hua[rootlocalhost tmp]# echo $firstname $lastname#父进程中没有这两个变量2.绝对路径执行(也需要执行权限)[rootlocalhost tmp]# /tmp/showname.shPlease input your first name: liuPlease input your last name:  huaYour full name is: liu hua[rootlocalhost tmp]# echo $firstname $lastname#父进程中没有这两个变量#注l相对路径和绝对路径执行需要文件的执行权限l脚本在子进程中执行所以父进程中没有$firstname $lastname两个变量l直接执行showname.sh可能会失败因为当前目录可能不在PATH中3.sh执行[rootlocalhost tmp]# sh showname.shPlease input your first name: liuPlease input your last name:  huaYour full name is: liu hua[rootlocalhost tmp]# echo $firstname $lastname#脚本在子进程中执行所以父进程中没有$firstname $lastname两个变量#sh执行不需要文件的执行权限4.source和.执行[rootlocalhost tmp]# . showname.shPlease input your first name: liuPlease input your last name:  huaYour full name is: liu hua[rootlocalhost tmp]# echo $firstname $lastnameliu hua[rootlocalhost tmp]# source showname.shPlease input your first name: liuPlease input your last name:  huaYour full name is: liu hua[rootlocalhost tmp]# echo $firstname $lastnameliu hua#脚本在父进程中执行所以有$firstname $lastname两个变量#不需要文件的执行权限
http://wiki.neutronadmin.com/news/286751/

相关文章:

  • 网站icp备案是什么意思怎么制作自己的链接
  • 网站建设教程在线软件技术网站怎么做
  • 网站正在建设中提示页上海网站制作最大的公司
  • 电子元器件在哪个网站上做装饰网站方案
  • 合肥企业网站建设公司哪家好php 网站301
  • 成都 网站建设wordpress改版权设置
  • 国外做的比较的ppt网站有哪些方面wordpress正文底部版权声明
  • 商务网站开发考题自己做网站流程
  • 亳州建设局网站免费注册自媒体账号
  • 做是么网站网络安全公司排名前十名
  • 江干区住房和城乡建设局网站建设网站的建设费用包括什么
  • 企业做网站优点郑州网络营销公司哪家好
  • 快速搭建网站后台网站建设文案详情
  • sql网站模板建设网站你认为需要注意哪些问题
  • 网站开发人员必备技能设计公司网站源码
  • 永康网站建设wordpress新用户默认角色设置
  • 如何做建材网站的线下推广淮安网站建设服务
  • 政务公开网站建设的亮点和建议上海最好的网站建设公司
  • 广告设计网站排行榜前十名有哪些苏州小程序开发外包
  • html 网站链接手机网站调用分享
  • 网站开发应用到的技术名词网站维护升级访问中
  • 五金加工东莞网站建设网站引导插件
  • 网站建设讲话稿如何注册公司地址定位
  • 做网站怎么设置会员如何建设一个视频小网站
  • 东莞营销网站建设价格做食物网站
  • 免费建设外贸网站还原wordpress站点地址恢复
  • 网上做网站 干对缝儿生意金蝶软件多少钱
  • 企业官网网站设计十大永久免费crm
  • 福建省网站建设有限公司盘锦做网站电话
  • 检察院门户网站建设方案漯河市源汇区建设局网站