Fancy alternative for old good test command.
var=123
if is equal $var 123.0; then
echo "it just works"
fi
if is not a substring $var "foobar"; then
echo "and it's easy to read"
fi
In order to use is.sh you can install it with one of following 1-liners:
# Unix-like
$ sudo sh -c 'cd /usr/local/bin && wget raw.githubusercontent.com/qzb/is.sh/latest/is.sh -O is && chmod +x is'
# NPM
$ npm install -g is.sh
If you don't want to install is.sh system-wide you can just download it and source it from your script:
$ wget raw.githubusercontent.com/qzb/is.sh/latest/is.sh
$ source ./is.sh
is equal $valueA $valueB
- checks if values are the same or if they are equal numbersis matching $regexp $value
- checks if whole value matches to regular expressionis substring $valueA $valueB
- checks if first value is a part of second oneis empty $value
- checks if value is emptyis number $value
- checks if value is a numberis gt $numberA $numberB
- true if first number is greater than second oneis lt $numberA $numberB
- true if first number is less than second oneis ge $numberA $numberB
- true if first number is greater than or equal to second oneis le $numberA $numberB
- true if first number is less than or equal to second oneis file $path
- checks if it is a fileis dir $path
- checks if it is a directoryis link $path
- checks if it is a symbolic linkis existent $path
- checks if there is a file or directory or anything else with this pathis readable $path
- checks if file is readableis writeable $path
- checks if file is writeableis executable $path
- checks if file is executableis available $command
- checks if given command is availableis older $pathA $pathB
- checks if first file is older than second oneis newer $pathA $pathB
- checks if first file is newer than second oneis true $value
- true if value is equal "true" or "0"is false $value
- opposite of is true $value
You can negate any condition by putting not in front of it.
$ is number "abc" && echo "number"
$ is not number "abc" && echo "not a number"
not a number
You can add a, an, and the articles before condition name.
$ is a number 5
$ is not a substring abc defghi
MIT
.sh文件执行方法 第一种 (需要文件具备可执行的权限,使文件具备执行方法:chmod u+x datelog.sh ,x为条件) 1、在任何路径下,输入该文件的绝对路径,例如: /root/datelog.sh就可执行该文件 2、cd到datelog.sh文件的目录下,例如:cd /root/进入目录 ,然后执行./datelog.sh 第二种 (不需要文件具备可执行的权限) 1、在该文件路径下
startup.sh (示例) #!/bin/bash #定义一些用户变量 APP_HOME=/opt/apiWeb APP_NAME=apiWeb.war LOG_FILE=out.log #使用说明,用来提示输入参数 usage() { echo "Usage: sh startup.sh [start|stop|restart|status]" exit 1 } #检查程序是否在运行 is_
学习使用zookeeper已经有一段时间了,%ZK_HOME%/bin目录下有几个常用的脚本文件,要想用好zookeeper我们必须要弄明白这几个脚本的含义和用法,在实际的生产环境下对于zookeeper自带脚本文件有时需要进行修改后使用,以便能更好地服从业务需求。 今天来总结一下zookeeper自带脚本的功能和脚本含义 在%Zk_HOME%/bin目录下有7个比较有用的脚本文件其中*.sh和*
错误一览 sbin/start-yarn.sh 执行失败 Starting resourcemanager ERROR: Attempting to operate on yarn resourcemanager as root ERROR: but there is no YARN_RESOURCEMANAGER_USER defined. Aborting operation. Startin
使用命令sh startup.sh -m standalone启动报错: ./startup.sh: 78: ./startup.sh: [[: not found ./startup.sh: 88: ./startup.sh: [[: not found ./startup.sh: 90: ./startup.sh: [[: not found ./startup.sh: 96: ./start
1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序。在这个例子中我们使用/bin/sh来执行程序。 当编写脚本完成时,如果要执行该脚本,还必须使其可执行。 要使编写脚本可执行: 编译 chmod +x filename 这样才能用./filename 来运行 2 注释 在进行shell编程时,以#开头的句子表示注释
0.前言 要求环境: ubuntu 18.04 一个已注册域名且解析已指向服务器ip acme.sh的github页面有中文说明 更多信息请参考官方wiki。本记录也大量引用官方中文指引 全程不需要sudo,使用sudo反而会引起预料之外的问题 1.安装 acme.sh sudo apt install cron socat curl https://get.acme.sh | sh echo
前些天,花了一些时间整理linux shell编程。看了一些简单的语法后,觉得还是不够深刻。想着,是不是可以直接查看一些开源软件的启动脚本快速提升shell编写能力。 下面来看看tomcat bin目录下的 start.sh 文件到底在做什么呢? 源码解析 #!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one
从Linux上下载出来catalina.sh,修改了一些设置之后重新上传到tomcat的bin目录下。 然后cd到tomcat的bin目录下执行 : sh startup.sh ,查看日志发现无反应; 重新执行 : sh shutdown.sh,控制台报错如下: Cannot find ./catalina.sh The file is absent or does not have execu
现象 在Linux环境下运行Tomcat,当执行 ./startup.sh 命令时报以下提示 Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program 原因 没有执行权限运行该程序 解决方法 在tomcat 的bin
使用acme.sh给Nginx配置HTTPS证书 本文在centos7,nginx/1.17.3操作,低版本的Nginx(1.14.2)会有问题,需要另外处理。 1. 安装 acme.sh 这里注意做hosts映射,不然安装不成功。 按提示映射访问不了的域名就可以了,一般设置为 vim /etc/hosts 在最后添加如下内容,IP可能需要更换 185.199.108.133 https://r
从tomcat官网上下载了apache-tomcat-5.5.36.zip,在window xp系统里面解压以后,直接放在了linux服务器上。 进入tomcat/bin目录,执行启动的时候出现如下错误: [root@test bin]# ./startup.sh Cannot find ./catalina.sh The file is absent or does not have execu
docker运行tomcat报错 Cannot find /usr/local/tomcat/bin/setclasspath.sh This file is needed to run this program 经过尝试,使用用dockerfile打包加入命令 RUN unset CATALINA_HOME 尝试后无效 搜索后,同样的问题有一篇文章:https://www.5axxw.com/q
执行命令: $ ~/.acme.sh/acme.sh --issue -d mydomain.me --standalone --keylength ec-256 --force 报错: Please add '--debug' or '--log' to check more details. See: https://github.com/acmesh-official/acme.sh/wi
Linux下如何写 .sh 脚本启动 项目 创建文件 mealcoupon.sh 内容如下: #!/bin/bash #这里可替换为你自己的执行程序,其他代码无需更改 APP_NAME=xhqy_yzf-1.0.0.war #项目的路径(替换成你项目的路径) PROJECT_LOCATION=/home/xpro/xhqy_jt #使用说明,用来提示输入参数 usage() { echo "U
aishell运行报错,提示需安装kaldi-lm local/aishell_train_lms.sh: train_lm.sh is not found. That might mean it's not installed local/aishell_train_lms.sh: or it is not added to PATH local/aishell_train_lms.sh: Us
目录 环境依赖 1、下载【build_chain.sh】 2、脚本命令参数 3、生成区块链配置文件ip_list: 4、调用build_chain.sh脚本构建区块链节点: 5、启动节点 6、查看节点进程 总结: 环境依赖 名称 版本 FISCO BCOS 2.0 openssl >=1.0.2 curl 未知 1、下载【build_chain.sh】 执行命令,安装openssl、curl(如果
HADOOP 命令sbin/start-dfs.sh 启动 报错 Error: Cannot find configuration directory: /etc/hadoop JAVA_HME is not set and could not be found 配置 hadoop-env.sh 文件位置为 hadoop-2.7.1/etc/hadoop。文件路径写你自己的jdk 和had
方法 使用Git Bash 添加conda到环境变量 激活conda # 激活环境 source activate # 退出环境 source deactivate # 或者 conda deactivate # 因为 DeprecationWarning: 'source deactivate' is deprecated. Use 'conda deactivate'. 运行shell
切换到bin目录下 #1 chmod +x *.sh #2 sh catalina.sh 通过 #3 sh startup.sh 启动成功
记录一下今天遇到的linux 启动tomcat遇到的问题: 在tomcat的bin 目录下执行 sh ./start.sh.sh 启动tomcat 报错:“Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program”
详细错误: configure: error: cannot find install-sh, install.sh, or shtool in "/home/tsit/jna-5.8.0/native/libffi" "/home/tsit/jna-5.8.0/native/libffi/.." "/home/tsit/jna-5.8.0/native/libffi/../.." make: *
在用命令 ./startup.sh 启动tomcat时报错: Cannot find /usr/local/tomcat/bin/setclasspath.sh This file is needed to run this program 在tomcat的bin目录下我们看下catalina.sh文件: vi catalina.sh 搜索下setclasspath: ?setclasspath