Linux bash fi

if..else..fi allows to make choice based on the success or failure of a command.

if..else..fi 允许根据命令的成功或失败进行选择。

if [ conditional expression ]
then
statement1
statement2
.
fi
if [ expression ]
then
Statement(s) to be executed if expression is true
fi

demo


if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
read ops
case $ops in
y) if apt-get install axel -y --force-yes
then echo "axel installed"
else echo "unable to install the axel. you are using sudo?" ; exit
fi ;;
n) echo "not possible usage apt-fast" ; exit ;;
esac
fi

https://stackoverflow.com/questions/7010830/bash-whats-the-use-of-fi

refs

https://bash.cyberciti.biz/guide/If..else..fi

https://www.tutorialspoint.com/unix/if-fi-statement.htm



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


Linux bash fi的更多相关文章

  1. linux bash关闭标准输出1(exec 1<&-)后重新打开

    linux bash shell的再次学习. 文件描述符: stdin,stdout 和 stderr 的文件描述符分别是 0,1 和 2(一个文件描述符说白了就是文件系统为了跟踪这个打开的文件而分配 ...

  2. 【转】Linux(BASH)命令搜索机制

    原文网址:http://www.mike.org.cn/articles/linux-linux-bash-command-search-mechanism/ 转自:Eric Cheung: Linu ...

  3. Linux Bash编程

    在Linux系统介绍中,介绍了shell的多个版本,现在的Linux发行版基本都默认使用bash(Bourne Again shell),兼容Bourne shell (sh),本文将简要介绍Bash ...

  4. Linux Bash命令杂记(tr col join paste expand)

    Linux Bash命令杂记(tr col join paste expand) tr命令 tr命令可以将输入的数据中的某些字符做替换或者是作删除 tr [-ds] STR d: 删除输入数据的中的S ...

  5. 转: windows 10使用原生linux bash命令行

    转: https://www.zybuluo.com/pandait/note/337430 windows 10使用原生linux bash命令行 linux bash windows-10 第一时 ...

  6. Linux Bash代码 利用for循环实现命令的多次执行

    Linux Bash代码 [yuanhao15@lu01 libsvm-rank-2.81]$ for ((i=0; i<=19; i++)) do ./svm-train -s 5 -c 10 ...

  7. linux BASH shell设置字体与背景颜色

    linux BASH shell下设置字体及背景颜色的方法. BASH shell下设置字体及背景颜色  echo -e "\e[31mtest\e[41m"  \e[30m 将字 ...

  8. Linux:-bash: ***: command not found

    Linux:-bash: ***: command not found,系统很多命令都用不了,均提示没有此命令. 突然之间linux很多命令都用不了,均提示没有此命令. 这应该是系统环境变量出现了问题 ...

  9. Linux Bash命令关于程序调试详解

    转载:http://os.51cto.com/art/201006/207230.htm 参考:<Linux shell 脚本攻略>Page22-23 Linux bash程序在程序员的使 ...

随机推荐

  1. 查看内核打印信息指令dmesg

    linux系统启动的时候打印的的信息非常重要,有时候需要看这些信息但是又不想重启,可以用dmesg这条指令.

  2. (08)-Python3之--类和对象

    1.定义 类:类是抽象的,一类事物的共性的体现.  有共性的属性和行为. 对象:具体化,实例化.有具体的属性值,有具体做的行为. 一个类 对应N多个对象. 类包含属性以及方法. class 类名: 属 ...

  3. Infrastructure as Code 行为驱动开发指南 https://www.ibm.com/developerworks/cn/devops/d-bbd-guide-iac/index.html

    Infrastructure as Code 行为驱动开发指南 https://www.ibm.com/developerworks/cn/devops/d-bbd-guide-iac/index.h ...

  4. The Go Blog Getting to Go: The Journey of Go's Garbage Collector

    Getting to Go: The Journey of Go's Garbage Collector https://blog.golang.org/ismmkeynote

  5. 关于js中each()使用return不能终止循环

    Jquery的each里面用return false代替break:return ture代替continue $(xx).each(function() { if(xx){ return false ...

  6. 请你尽量全面的说一个对象在 JVM 内存中的结构?

    从 Java 14 开始,Project Valhala引入了 Value Type(或者称为 inline type),参考: Valhalla: https://openjdk.java.net/ ...

  7. Spring Boot 系列总结

    Spring Boot 系列总结 1.SpringBoot自动装配 1.1 Spring装配方式 1.2 Spring @Enable 模块驱动 1.3 Spring 条件装配 2.自动装配正文 2. ...

  8. 手机用itunes安装更新系统

    1.[Shift+更新]:仅对固件进行更新,保留现有资料和已经安装的程序.但是已经越狱的iPhone或iPad禁止使用此方法!否则有后遗症!没有越狱的iPhone或iPad则可以直接使用此方式.2.[ ...

  9. linux环境变量 shell变量 command not found解决方法(转)

    在Ubuntu.centos中有如下几个文件可以设置环境变量1./etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文 ...

  10. J - What Are You Talking About(map,字典树)

    题意:上部分是单词表,下部分是句子,翻译句子.START开始,END结束. 思路:简单字典树. Ignatius is so lucky that he met a Martian yesterday ...