输出android目录结构的一个shell 脚本
2013-07-07 21:12
381 查看
研究android时,我总想知道它的目录结构,于是写出了下面这个小脚本。adb有个特性,让使用unix/linux的人很反感,它行尾用\r\n,在调试程序时\r时常捣乱。在这个脚本中做了处理。
#!/bin/bash
# usage: list_android [-v]
# func: list_file
# arg1: directory
# arg2: indent
list_file() {
adb shell "ls -F $1 2>/dev/null" | \
while read i; do
fn=$(echo $i | cut -f2 -d ' ' | tr -d '\r')
if test "$verbose" = "true"; then
echo "$2"$(adb shell ls -ld ${1}/$fn)
else
echo "$2"$fn
fi
if test
"$1" =
"/" -a \(
"$fn" =
"proc" -o
"$fn" =
"sys" \)
then
:
elif test
"${i:0:1}" =
'd';
then
list_file ${1}/$fn
"$2 "
fi
done
}
if test
"$1" =
'-v';
then
verbose=true
fi
list_file
'/' ""
#!/bin/bash
# usage: list_android [-v]
# func: list_file
# arg1: directory
# arg2: indent
list_file() {
adb shell "ls -F $1 2>/dev/null" | \
while read i; do
fn=$(echo $i | cut -f2 -d ' ' | tr -d '\r')
if test "$verbose" = "true"; then
echo "$2"$(adb shell ls -ld ${1}/$fn)
else
echo "$2"$fn
fi
if test
"$1" =
"/" -a \(
"$fn" =
"proc" -o
"$fn" =
"sys" \)
then
:
elif test
"${i:0:1}" =
'd';
then
list_file ${1}/$fn
"$2 "
fi
done
}
if test
"$1" =
'-v';
then
verbose=true
fi
list_file
'/' ""
相关文章推荐
- linux、shell脚本实例一“查找一个文件或者目录 找到了提示 没找到则输出未找到”
- 编写一个SHELL脚本,可以获得指定目录下的所有文件及文件夹的大小。输出的样式与 ls -lh 命令相同。
- Linux系统目录结构,Shell脚本;关闭和开启防火墙
- Android调用shell脚本并获得输出
- shell脚本输出文件夹下所有目录的绝对路径
- 一个AndroidStudio项目的目录结构
- shell脚本判断一个目录是否为空的方法
- Linux下使用Shell脚本删除一个目录下的所有子目录和文件
- 一个监控LINUX目录和文件变化的Shell脚本分享
- shell 脚本中将输出内容赋值给一个变量时不换行
- 一个简单的创建ndk文件目录结构来编译源文件的框架的小脚本
- shell脚本随机输出一个文件的25行
- 一个简单的转换输出的shell脚本代码
- 如何用shell脚本删除目录结构为日期的目录(date)
- 显示目录结构的shell脚本
- shell中获取android源码编译输出目录
- shell 脚本,将/etc/目录下所有的软链接文件输出
- vim独家秘技两条(1)在任意列中插入等差数列(非插件)(2)利用shell命令插入某个目录下的所有文件名(可用于cocos2d-x android的.mk脚本配置)(下)
- shell脚本随机输出一个文件的25行
- shell 脚本中将输出内容赋值给一个变量时的换行问题