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. kiosk-mode,免密码登陆, sideload Windows Store apps 等

    MVVM带来的性能问题及其解决方案  MVVM 和语言性能提示:https://msdn.microsoft.com/zh-cn/library/windows/apps/xaml/mt628050. ...

  2. 【温故Delphi】双击工程文件打开软件

    问题描述 大部分软件都有鼠标双击文件,就能打开所关联的软件并打开所选工程,这是如何做到的呢? 把文件关联到一个程序中,双击文件来启动程序,那么这个文件名称就是这个程序的命令行的一个参数. 所以要想实现 ...

  3. iis下设置php最大执行时间

    php在执行中常见错误: The FastCGI process exceeded configured request timeout: FastCGI process exceeded confi ...

  4. Android观察者模式的简单实现demo

    观察者模式就是:当一个对象的状态发送改变时,所有依赖于它的对象都能得到通知并被自动更新. 下面介绍一种简单的使用方法,(下面有demo链接)先看一下project的目录构成: ObserverList ...

  5. 一个日期的下一个星期五 next_date

    select next_day('18-5月-2001','星期五') nxt_day from dual;

  6. Redis第二篇(Redis基本命令)

    -x     从标准输入读取一个参数 such as: echo –en “shaw” |./redis-cli –x setname == set name shaw -r     重复执行一个命令 ...

  7. <转>简单之美——系统设计黄金法则

    作者: 包云岗  发布时间: 2012-05-19 13:06  阅读: 3036 次  推荐: 1   原文链接   [收藏] 最近多次看到系统设计与实现的文章与讨论,再加上以前读过的其他资料以及自 ...

  8. 用js实现瀑布流的一种简单方法

    现在说瀑布流式布局似乎有点晚了,但是每一项技术都是向着“精”和“简”的方向在不断发展,在发展到极致之前,需要一个相当漫长的过程,因此,从这个角度来说,当瀑布流被应用得越来越多的时候,反而更应该讨论它, ...

  9. Freemarker日期格式化处理

    基本参数: date: 只显示日期,不显示时间.如${createTime?date} 或${createTime?date('yyyy-MM-dd')} time: 只显示时间,不显示日期如${cr ...

  10. Java中区别.toString() ,(String),valueOf()方法

    在java项目的实际开发和应用中,常常需要用到将对象转为String这一基本功能.本文将对常用的转换方法进行一个总结.常用的方法有Object.toString(),(String)要转换的对象,St ...