bash - filename=${1:-/etc/hosts} 和 filename=/etc/hosts 的区别
来源:互联网 发布:淘宝卖家登陆中心 编辑:程序博客网 时间:2024/05/16 17:43
举例如下:
filename=/etc/hostsif [ -r "$filename" ] && [ -s "$filename" ]; then md5sum $filenameelse echo "$filename cannot be processed"fi
filename=${1:-/etc/hosts}if [ -r "$filename" ] && [ -s "$filename" ]; then md5sum $filenameelse echo "$filename cannot be processed"fi
如果 $1 为空或不存在,则把 /etc/hosts 赋值给 filename 变量,更一般的解释如下:
${parameter:-value} 如果 parameter 不存在或为空则用 value 替代表达式的值,否则用 parameter 替代表达式的值
点击此处查看问题来源
详情请参考 Bash Manual
1 0
- bash - filename=${1:-/etc/hosts} 和 filename=/etc/hosts 的区别
- hostname和/etc/hosts的区别
- hostname和/etc/hosts的区别
- hostname和/etc/hosts的区别
- hostname和/etc/hosts的区别
- /etc/hosts.allow和/etc/hosts.deny的作用
- /etc/hosts.allow和/etc/hosts.deny
- /etc/hosts.allow和/etc/hosts.deny
- Linux 的/etc/hosts
- /etc/hosts
- linux下/etc/hosts 和hostname文件的区别
- linux修改主机名称: hostname和/etc/hosts的区别
- 关于/etc/hosts.equiv和$HOME/.rhosts的区别
- linux下/etc/hosts 和hostname文件的区别
- linux下/etc/hosts 和hostname文件的区别
- linux下/etc/hosts 和hostname文件的区别
- 修改主机名(/etc/hostname和/etc/hosts区别)
- 修改主机名(/etc/hostname和/etc/hosts区别)
- Java四种线程池的使用
- JS或者jQuery常用知识
- gem5 abstractMemory simpleMemory
- hdu acm 1498 50 years, 50 colors
- [Excel VBA]状态栏如何显示文字 ?
- bash - filename=${1:-/etc/hosts} 和 filename=/etc/hosts 的区别
- 2016 app store 审核非常严厉
- 栈的简单实现——使用C++容器库(STL Stack)
- [c++基础]valarray模板详解
- Genymotion 2.6.0 with Google Service and ARM apps
- 定制流程构件
- (一)搜索&&广告&&营收
- 数字信号处理 DSP(一)
- JSP实现分页功能