shell test和find命令实例解析
来源:互联网 发布:js decodeuri utf8 编辑:程序博客网 时间:2024/05/21 11:29
shell test和find命令实例解析
下面以\build\core\product.mk相关部分来学习
define _find-android-products-files$(shell test -ddevice && find device -maxdepth 6 -name AndroidProducts.mk) \ $(shell test -d vendor && find vendor -maxdepth 6 -nameAndroidProducts.mk) \ $(SRC_TARGET_DIR)/product/AndroidProducts.mkEndef
Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值、字符和文件三个方面的测试,这方面参考http://www.runoob.com/linux/linux-shell-test.html
上面例子同时也用到了find命令
test -d device&& find device -maxdepth 6 -name AndroidProducts.mk
test -d device表示如果device存在且为目录则为真,则会执行find命令find命令在device目录下,最大深入6层子目录来查找名字为AndroidProducts.mk的文件
对于find命令,在-之前的字符串表示path(目录,这里是device),之后是expression(表达式,这里是-maxdepth 6 -name AndroidProducts.mk),
-maxdepth 6 设定递归搜索的目录层级,1为在当前目录下,即不递归搜索。
-name name, -iname name : 文件名称符合 name 的文件。iname 会忽略大小写
find命令找到AndroidProducts.mk后将查找到的子目录和文件全部进行显示,这就是find命令的输出,比如我在device下find的结果
图1
这里shell是函数,它的参数是操作系统Shell的命令,比如test,shell函数把执行命令后的输出作为函数返回,上面命令包的作用是在device、vendor目录下查AndroidProducts.mk,把device、vendor和(SRC_TARGET_DIR)/product/AndroidProducts.mk所在子目录和文件全部进行显示
命令包_find-android-products-files的值是AndroidProducts.mk文件列表,见上图
- shell test和find命令实例解析
- shell实例(十六) ----find和xargs命令
- shell实例(十七) ----find和xargs命令
- Shell Test命令参数解析
- Shell Test命令参数解析
- Shell Test命令参数解析
- Shell脚本test命令使用总结和实例
- Linux find命令实例解析
- Linux Shell : Test命令参数解析
- Linux Shell : Test命令参数解析
- Linux Shell : Test命令参数解析
- linux Shell : Test命令参数解析
- Linux Shell : Test命令参数解析
- find和grep命令实例
- Shell 函数 和 Shell echo命令 和 test命令
- shell if语句和test命令
- shell介绍和命令实例
- shell条件判断之test命令实例详解
- Python调用哈工大语言云(LTP)API进行自然语言处理
- 鱼眼校正原理
- Instant Complexity(dfs 模拟)
- 关于面试中的TCP和UDP怎么用自己的话给面试官说
- SQLiteDatabase介绍和一点点的使用
- shell test和find命令实例解析
- 重要知识记录
- 通过浏览器链接启动本地Activity
- C++(文件和流)
- IE6的3px bug解决方法
- UbuntuKylin 16.04 安装Node开发环境
- Bootstrap分页插件--Bootstrap Paginator
- LPDMvvmKit系列之UITableView的改造
- MYSQL 注册