if fi shell 脚本
发布日期:2021-06-30 18:52:29
浏览次数:2
分类:技术文章
本文共 406 字,大约阅读时间需要 1 分钟。
weiqifa@ubuntu:~/logcat$ source test.sh please input the packageNameweiqifa@ubuntu:~/logcat$ source test.sh aainput okweiqifa@ubuntu:~/logcat$ cat test.sh #!/bin/bashif [ -z "$1" ];thenecho "please input the packageName"elseecho "input ok"fiweiqifa@ubuntu:~/logcat$
1、开头还是要有#!/bin/bash
2、if 和[之间要有一个空格,否则会提示 {syntax error near unexpected token `then'}
3、[ -z "$1" ] $1是输入的第一个参数,-z跟左边的[也要有空格,不然判断结果都是跑else了。
转载地址:https://linus.blog.csdn.net/article/details/42077317 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年05月02日 12时03分40秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!