from:Sep 23 2016


mathematical operation:

floating number,bc calculator:

we can also use bc in shell scripts:


if - then - else

number comparison:

n1 -eq n2

n1 -ge n2

n1 -gt n2

n1 -le n2

n1 -lt n2

n1 -ne n2

if - then - elif, notice that the second elif won't be executed, though it's also right.


strings comarison:

str1 = str2

str1 != str2

str1 < str2

str1 /> str2

-n str1

-z str1


using file comparisons:

                  -d file    checks if file exists and is a dictory

-e file    checks if file exists

-f file     checks if file exists and is a file

-r file     checks if file exists and is readable

                 -s file     checks if file exists and is not empty

-w file    checks if file exists and is writable

-x file     checks if file exists and is executable

-o file     checks if file exists and is owned by the current user

-G file    checks if file exists and the default group is the same as the current user

file1 -nt file2   checks if file1 is newer than file2

file1 -ot file2   checks if file1 is older than file2


considering compound testing


working with advanced if-then features

((expression))

var++

var--

++var

--var

!              logical negation

~              bitwise negation

**             exponentiation

<<

>>

&

|

&&

||

notice the '++' of the screenshot.

it's writen of var++ not $var++


using double brackets

[[ expression ]]

the double bracket command provides advanced features for string comparisons---pattern matching.


Considering the case command:

case variable in

pattern1 | pattern2) command1;;

pattern3) command2;;

*) default commands;;

esac


The for command:


The while command:


The until command:

linux shell program summary的更多相关文章

  1. linux shell 报错 Syntax error: Bad for loop variable

    在linux下写了一个简单的shell,循环10次. test.sh #!/bin/bash ## ##循环10次 ## ; i<; i++)); do echo Good Morning ,t ...

  2. 面试题总结之Linux/Shell

    Linux Linux cshrc文件作用 Linux如何起进程/查看进程/杀进程 Linux 文件755 代表什么权限 Linux辅助线程 Linux进程间通信方法 pipeline,msgq... ...

  3. Bash For Loop Examples for Your Linux Shell Scripting--ref

    There are two types of bash for loops available. One using the “in” keyword with list of values, ano ...

  4. 老李分享:《Linux Shell脚本攻略》 要点(四)

    老李分享:<Linux Shell脚本攻略> 要点(四)   1.IP地址的正则表达式: [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} 2. ...

  5. Linux Shell基础(下)

    Linux Shell基础(下) 目录 一.shell特殊符号cut命令 二.cut.sort.wc.uniq命令 三.tee.tr.split命令 四.简易审计系统 五.fork, exec, so ...

  6. linux shell脚本之-变量极速入门与进阶(1)

    1,如果创建shell脚本? 使用任意文本编辑软件,一般为vim,创建.sh结尾的文件,在文件的最开头用 #!/bin/bash 注明shell的类型 如: ghostwu@dev:~/linux/s ...

  7. linux shell 脚本攻略学习20--awk命令入门详解

    awk生于1977年,创始人有三个,分别为 Alfred Aho,Peter Weinberger, 和 Brian Kernighan,名称源于三个创始人的姓的首字母. 作用:处理文本文件. awk ...

  8. 面试总结之Linux/Shell

    Linux Linux cshrc文件作用 Linux如何起进程/查看进程/杀进程 Linux 文件755 代表什么权限 Linux辅助线程 Linux进程间通信方法 pipeline,msgq... ...

  9. 一个改动配置文件的linux shell script

    不久以前,以前搜到一篇博客是读取配置文件的,http://www.cnblogs.com/bo083/archive/2012/11/19/2777076.html,用到如今,感觉十分方便.感谢作者. ...

随机推荐

  1. javascript里的继承

    js里面继承的方式, 1. 类式继承,通过构造函数的继承 function extend(subClass, superClass){ var F = function(){}; F.prototyp ...

  2. hibernate配置文件中的schema="dbo"在MySQL数据库不可用

    把项目的数据库由SQL Server更改为MySQL之后,发现hibernate报错. 问题在于schema="dbo",使用SQL Sever数据库时正常,使用MySQL数据库需 ...

  3. appium踩过的坑(1):NoClassDefFoundError

    1.引入jar包错误导致的错误: 引入的jar包引起的 应该引入下面的jar包

  4. 12个Linux进程管理命令介绍(转)

    12个Linux进程管理命令介绍 [日期:2015-06-02] 来源:Linux中国  作者:Linux [字体:大 中 小]   执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的 ...

  5. String、StringBuffer、StringBuilder的一些小经验……

    一说String.StringBuffer和StringBuilder,想必大家都很熟悉,这三者经常在我们的面试题中出现,我也是看到了关于这三个的经典面试题,才触动了我之前工作中的一些经历,故而根据我 ...

  6. 【线段树】bzoj1756 Vijos1083 小白逛公园

    我们知道,求一段序列的最大子段和是O(n)的,但是这样是显然会超时的. 我们需要一个数据结构来支持修改和计算的操作,对于这种修改一个而查询区间的问题,考虑使用线段树. 在线段树中,除了左端点,右端点, ...

  7. 黑马程序员_Java基础:集合总结

    ------- android培训.java培训.期待与您交流! ---------- 一.集合概念 相信大家都知道,java是一门面向对象的编程语言,而对事物的体现都是以对象的形式,所以为了方便对多 ...

  8. 链接报error LNK2019: unresolved external symbol错误,解决

    http://blog.163.com/aiding_001/blog/static/22908192011102224344450/ 某次编写一个COM组件,接口定义好之后,增加了ZRX代码后编译链 ...

  9. 一些有用的Javascript Function :-)

    1.验证完整的日期格式:(yyyy-MM-dd)function checkDate(RQ) { var date = RQ; var result = date.match(/^(\d{1,4})( ...

  10. 01 选择 Help > Install New Software,在出现的对话框里,点击Add按钮,在对话框的name一栏输入“ADT”,点击Archive...选择离线的ADT文件,contact all update ....千万不要勾选点击Add按钮,在对话框的name一栏输入“ADT”,点击Archive...选择离线的ADT文件,contact all update ....千万不要勾

    引言 好久没碰过android,今天重新搭建了一次环境,遇到的问题记录下载.共以后使用. 安装 软件的软件有jdk+eclipse+adt+sdk 主要记录安装adt和sdk的过程,注意,adt和sd ...