bash shell脚本实用方法
来源:互联网 发布:网络选修课网站 编辑:程序博客网 时间:2024/06/05 02:11
(1)在查找的文件后执行相应的操作
$ find -name "Makefile" | xargs ls -l
$ find china/ -name via -prune -o -name logo -prune -o -type f \( -name 'Makefile' -o -name '*.c' -o -name '*.h' \) -print
注意:
-name via -prune 表示忽略via目录
-o 表示继续连接后面的参数
-print 表示打印符合条件的内容
$ find china/ -name via -prune -o -name logo -prune -o -type f \ -name 'Makefile' -o -name '*.c' -o -name '*.h' \)-print0 | xargs -0grep --color -nr "aa"
注意:
-print0 会把符合条件的内容打印成一行,如果没有和 xargs -0 结合使用,会只打印符合条件的第一个 -name 'Makefile' 的内容
(2)shell的变量赋值只有=,没有:=这种方式,后者后报错,还要注意=前后都不能有空格,否则也会报错
(3)android 中 build/envsetup.sh 的 EOF 解释
cat命令是linux下的一个文本输出命令,通常是用于观看某个文件的内容的;EOF是“end of file”,表示文本结束符。结合这两个标识,即可避免使用多行echo命令的方式,并实现多行输出的结果。
alex@android:~/android/experiment$ cat << EOF > cat_eof.sh> #! /bin/bash> author:os-alex> date :2014-03-16> EOFalex@android:~/android/experiment$ ll cat_eof.sh -rw-r--r-- 1 alex os-group 46 3月 16 16:27 cat_eof.shalex@android:~/android/experiment$ cat cat_eof.sh #! /bin/bashauthor:os-alexdate :2014-03-16alex@android:~/android/experiment$
EOF只是标识,不是固定的这里的"AAAA”就代替了“EOF”的功能。结果是相同的。
alex@android:~/android/experiment$ cat >> cat_AAAA.sh <<AAAA> #! /bin/bash> we try AAAA for example> author:os-alex> date :2014-03-16> end here.> AAAAalex@android:~/android/experiment$ ll cat_AAAA.sh -rw-r--r-- 1 alex os-group 80 3月 16 16:35 cat_AAAA.shalex@android:~/android/experiment$ cat cat_AAAA.sh #! /bin/bashwe try AAAA for exampleauthor:os-alexdate :2014-03-16end here.alex@android:~/android/experiment$
1 0
- bash shell脚本实用方法
- bash shell脚本执行方法总结
- bash shell脚本执行方法总结
- bash shell脚本执行方法总结
- Shell bash 脚本语法
- Bash shell脚本备忘
- 几个bash shell脚本
- Shell bash 脚本语法
- Shell bash 脚本语法
- Shell bash 脚本语法
- 系统管理中 bash shell 脚本常用方法总结(转)
- 系统管理中 bash shell 脚本常用方法总结(转)
- 系统管理中 bash shell 脚本常用方法总结
- bash shell脚本执行的几种方法
- bash shell脚本执行的几种方法
- bash,dash以及执行shell脚本的方法
- 实用的shell脚本
- linux shell 实用脚本
- 十条看起来不错的编程观点
- 凸多面体
- FFRFFFFFFF
- PKU 2891:Strange Way to Express Integers(中国剩余定理非互质)
- angularjs的事件 $broadcast and $emit and $on
- bash shell脚本实用方法
- Lazy Loading In AngularJS
- AngularJS 学习笔记(邹业盛)
- controller 间共享数据
- Android中preTranslate和postTranslate
- dom对象与jquery对象转换
- arndale octa开发板编译u-boot和kernel
- 【黑马程序员】Java基础加强15:反射Reflect
- 求n的最小值