您的位置:首页 > 运维架构 > Shell

输出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
'/' ""
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: