if 条件判断格式

if [ ! -f file.txt ];then

   cmd

else

  cmd

fi

注1:! 代表非。不存在文件就成功。

注2:再有参数 变量 需要 [] 阔起

1


运算书写写格式

变量1 = 

变量1 = `expr 变量1 + `

结果:”变量1 =  + ” =  

1


for 循环格式

for i in 值1 值2 值3 值4;do

   cmd

done

注:值1与值2.. 之间使用空格分开

1


Shell 脚本格式注意事项的更多相关文章

  1. linux:shell脚本格式

    shell脚本格式:     #!/bin/bash //第一行指定bash     命令群.....          例子:     #!/bin/bash     DESCDIR='/tmp/t ...

  2. Jmeter中Bean shell脚本格式修改为utf-8

    遇到的问题: 在做 一个发贴的接口测试时发现,发送数字+纯字母贴子时,可以正常请求成功.但当贴内容为中文时,服务端编码为乱码??. 原因: jmeter中,shell脚本的默认的格式为GBK,所以我在 ...

  3. shell脚本格式的几点注意:格式严格,空格不能随便出现(一写就记不住)

    shell脚本中,不能随意添加空格,否则出错: 1,=等号两边必须无空格.否则出错.如i =$1和i= $1都是错的.但是在()内部不限制如for ((i= 1;i < 3;i= i+1))是正 ...

  4. shell脚本编写注意事项

    shell中赋值变量时不能有空格 之前写python写习惯了 test = ‘free -m’ 在shell中不能有空格 test='free -m' 而且使用管道符之前要留空格 test='free ...

  5. Linux运维初级教程(一)Shell脚本

    序,掌握shell脚本是linux运维工程师的最基础技能. 一.脚本语言 与高级语言不通,脚本语言运行时需要调用相应的解释器来翻译脚本中的内容. 常见的脚本语言有Shell脚本.Python脚本.ph ...

  6. Linux Shell 脚本入门

    linux shell 脚本格式 #!/bin/sh#..... (注释)命令...命令... 使用vi 创建完成之后需设置权限 chmod +x filename.sh 执行命令: ./filena ...

  7. Linux学习之路(三)Shell脚本初探

    本文参考链接:http://www.runoob.com/linux/linux-shell.html 基本说明 Shell脚本(shell script)是一种为shell编写的脚本程序.其中she ...

  8. troubleshooting-执行导数shell脚本抛异常error=2, No such file or directory

    Cannot run program "order_log.sh" (in directory "/data/yarn/nm/usercache/chenweidong/ ...

  9. shell 脚本基础与条件判断

    #!shell脚本格式决定专业性 #!/bin/bash #filename:脚本名 #author:作者 #date:时间 #脚本作用 脚本的执行方式  #脚本名为wk.sh 绝对路径 /root/ ...

随机推荐

  1. git 创建新分支并推送到远程分支

      git branch test git checkout test git push origin test:test git branch --set-upstream-to origin/te ...

  2. Ubuntu下安装LNMP

    1.安装mysql sudo apt-get install mysql-server mysql-client 2.安装nginx sudo apt-get install nginx 安装完后重启 ...

  3. 20.react库 入门

    vue插件: 使用方式:Vue.use(插件名称); {}/function 1.对象 export default { install(Vue,options){ } } 2.函数 export d ...

  4. python中字符串格式化的四种方法

    name = "huangemiling" age= 10 address = 'nanjing' print("My name is %s,age is %d,I co ...

  5. redis,缓存雪崩,粗粒度锁,缓存一致性

    1, redis单线程为什么快 io多路复用技术 单线程避免多线程的频繁切换问题 memcache缺点 kv形式数据 没有持久化mongodb 海量数据的访问效率 mr的计算模型文档就是类似json的 ...

  6. post方式接口测试(一)_新建测试用例

    第一种方式:拷贝别人的 第二种方式:自己创建 二.打开浏览器(此处chrome),F12打开开发模式,输入网址登录,此时可获取到登录的 Request URL 二.打开postman,进入自己的Col ...

  7. android studio样式文件汇总

    android studio样式文件汇总:shape.Theme|styles .selector 1:shape shape用于设定形状,有6个子标签,各属性如下: res/drawable/sty ...

  8. linux iptables 防火墙简介

    iptables防火墙简介 Netfilter/Iptables(以下简称Iptables)是unix/linux自带的一款优秀且开放源代码的安全自由的基于包过滤的防火墙工具,它的功能十分强大,使用非 ...

  9. 【JVM】-NO.110.JVM.1 -【JDK11 HashMap详解】

    Style:Mac Series:Java Since:2018-09-10 End:2018-09-10 Total Hours:1 Degree Of Diffculty:5 Degree Of ...

  10. cocos2dx 实现文字的一键复制功能(IOS、Android)

    1.IOS篇(用OC和C++混编) 头文件声明: public static void copy(std::string str); 实现如下: void copy(std::string str) ...