Ubuntu & Android 技巧

66 篇文章 0 订阅
50 篇文章 0 订阅
过滤空行
grep "^\s*[^# \t].*$" filename

#C++模式注释的删除。
#Delete the line begins with //
#首先删除//在行首的行
sed -i '/^[ \t]*\/\//d' $file

#Delete the line ends with //
#注意已经除去了 //在行首的情况,下面匹配除去URL的//部分,因为代码中有一部分中有
#URL,形如fun("ftp://")
sed -i 's/\/\/[^"]*//' $file

#删除以C语言中注释只在一行的行
sed -i 's/\/\*.*\*\///' $file

#Delete the lines between /* and */
#删除C语言中注释跨行的情况
sed -i '/^[ \t]*\/\*/,/.*\*\//d' $file

#ifndef __ARM_NEON__
#error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
#endif

查看so文件的函数列表
find -name "*.so" | xargs -t -I {} nm -D {}
find -name "*.so" | xargs -t -I {} objdump -tT {}

查看 so 的依赖库
find -name "*.so" | xargs -t -I {} objdump -x {} | grep NEEDED

Native 层启动 APK
system("am start -n com.liuyin.MediaPlayer/.MainActivity -d http://xxx.com/xxx.ts");

wget 下载重定向文件,保存为 Save.data
wget -d -O Save.data "http://www.redirect.com/"   #wget 可以重定向,只需要加引号即可

http://pan.baidu.com/share/home?uk=xxxxxx,我懂的,

for((i=1;i<=10;i++)); do echo $(expr $i); done;

只找当前目录(除 .)
find -maxdepth 1 ! -name '.' -type d

列出当前目录下子目录名
for i in $(find -maxdepth 1 ! -name '.' -type d); do basename $i; done;

列出当前目录下子目录名分别打包
for i in $(find -maxdepth 1 ! -name '.' -type d); do tar jcvf $(basename $i).tar.bz2 $i; done

socat 模拟 http client(注意read.txt一定要符合HTTP标准,否则得不到正确结果)
socat -u open:request.txt!!open:response.txt,create,trunc tcp:www.baidu.com:80
socat -u open:request.txt!!open:response.txt,create,append tcp:www.baidu.com:80

socat 模拟 http server
socat open:index.txt!!open:request.txt,create,append tcp-listen:80,reuseaddr,fork

socat 发送文件后,就把连接断了,模拟 http client 不太方便。可使用 netcat 模拟 http client。

netcat 模拟 http client(注意read.txt一定要符合HTTP标准,否则得不到正确结果)
type request.txt | nc baidu.com 80 > response.txt

vi 替换
g/str1/s//str2/g

任意目录 NDK 编译
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk

当前 activity
adb shell dumpsys activity activities | grep 'Recent #0'

sudo apt-get install ia32-libs build-essential

dpkg -l | grep xxxxsudo apt-get remove --purge xxxx

adb shell dumpsys activity intentsadb shell dumpsys activity broadcasts
adb shell dumpsys activity providers
adb shell dumpsys activity servicesadb shell dumpsys activity activities
adb shell dumpsys activity processes
ifconfig eth0
ifconfig eth0 192.168.0.125
ifconfig eth0 promisc
ifconfig eth0 -promisc
ifconfig eth0 hw ether 00:14:CC:00:1A:00
dhclient
ifup eth0
ifdown

1、设置属性
adb shell getprop media.stagefright.cache-params
adb shell setprop media.stagefright.cache-params 1572864/20971520/15000000

2、Android logcat, 打印 XXX 或者 YYY
adb logcat -c; adb logcat | grep -E '^|XXX|YYY';
adb logcat -c; adb logcat -v time 2>&1 | tee logcat.txt;
adb -s 192.168.1.32 logcat -c; adb-s192.168.1.32 logcat | grep -E '^|XXX|YYY'
adb -s emulator-5554 logcat -c; adb -s emulator-5554 logcat | grep -E '^|XXX|YYY'

3、批量 push 到要 push 的文件夹下
find -name "libstagefright*.so" -o -name "libmediaplayerservice.so" | xargs -t -I {} adb push {} /system/lib;
find . -type f -mtime -1 | xargs -t -I {} adb push {} /system/bin;
find $OUTBIN/ -type f -mmin -10 | xargs -t -I {} adb -s 10.9.44.138:5555 push {} /system/bin;

4、启动某应用
adb shell am start -a android.intent.action.VIEW -d http://www.baidu.com/
adb shell am start -n com.liuyin.MediaPlayer/.MainActivity -d http://www.xxxx.com/xxxx.ts

5、挂载目录
adb shell mount -o remount, rw /system

6、抓屏
export PNG_FILE=/data/$(date +%Y_%m_%d_%H_%M_%S).png; adb shell screencap -p ${PNG_FILE}; adb -s 10.9.44.138:5555 pull ${PNG_FILE} .;

7、在当前目录下搜索文本 'TEXT'(含子目录)
grep -r -n 'TEXT' *

8、排除指定文本
grep -v -e "noprint_a" -e "dont_show" text.txt

9、批量替换文件内容
find -type f | xargs sed -i "s/source/target/g"for f in $(find $1 -type l); do [ -e $f ] && sed -i "s/source/target/g" $f; done

10、批量替换文件名
rename 's/source/target/' *;
for i in $(find -name *.hh); do mv $i $(echo $i|sed 's/\.hh/\.h/'); done

11、显示目前所有文件系统的可用空间及使用情形
df -h
显示当前文件夹空间
du -sh *

12、User AgentMozilla/5.0 AppleCoreMedia/1.0.0.8J2 (iPad; U; CPU OS 6_0 like Max OS X; en-us) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25

13、Ubuntu 64 运行 32 位程序
sudo apt-get install ia32-libs

14、JAVA 访问 SystemProperties
a.选择 Eclipse 工程属性页(Properties)->Java Build Path->Libraries->Add External JARs...->选择AndroidSDK\platforms\android-##\data\layoutlib.jar->OK
b.增加 import android.os.SystemProperties;
c.SystemProperties.set("MediaPlayer.MediaURL", "http://192.168.0.11:80/MediaFile.ts");
d.SystemProperties.get("MediaPlayer.MediaURL");

15、删除无效软连接
a.symlinks -d -r ./
b.for f in $(find $1 -type l); do [ -e $f ] && rm -f $f; done

16、删除 '.svn' 和 '.repo' 文件
find -name '.svn' -o -name '.repo' | xargs rm -rf

17、添加用户
sudo useradd -m -s /bin/bash yourname

18、添加管理员权限在管理员帐户下,
sudo adduser <username> sudo

19、删除软件
sudo apt-get remove --purge softwarename

20、Linux下查看 tcp 连接数及状态
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

21、注销其他已登陆用户
pkill -kill -t pts/1

22、调试 Native 代码用 ndk-build 编译 HelloWorld, Eclipse Export 导出 apk, 安装 apk,ndk-gdb-py --project=D:\Workspace\HelloWorld --start

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值