(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
> EOF
alex@android:~/android/experiment$ ll cat_eof.sh
-rw-r--r-- 1 alex os-group 46 3月 16 16:27 cat_eof.sh
alex@android:~/android/experiment$ cat cat_eof.sh
#! /bin/bash
author:os-alex
date :2014-03-16
alex@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.
> AAAA
alex@android:~/android/experiment$ ll cat_AAAA.sh
-rw-r--r-- 1 alex os-group 80 3月 16 16:35 cat_AAAA.sh
alex@android:~/android/experiment$ cat cat_AAAA.sh
#! /bin/bash
we try AAAA for example
author:os-alex
date :2014-03-16
end here.
alex@android:~/android/experiment$