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

常用Shell命令1

2016-06-02 12:48 417 查看
awk过滤

grep bid=12007 /usr/local/openresty/nginx/logs/error.log | awk -F '\\[ValidateTest\\] |, client' '{print $2}' > ~/Downloads/battle_12007_server.log

nginx的启动和关闭:

/usr/local/openresty/nginx/sbin/nginx

/usr/local/openresty/nginx/sbin/nginx -s stop

时间过滤:

grep 'ValidateTest' ../logs/error.log | awk '$1$2 >="2015/12/2615:00:00" && $1$2 <= "2015/12/2616:00:00"' | more

字符替换:

$ sed -i -e ‘s/foo/bar/g’ myfile.txt

-e: 表达式
-i:表示直接替换源文件

字符裁剪

grep 'ValidateDG' test.log |cut -c26- > ~/Downloads/battle_client_40916_2.log

cut -c26-: 去掉前面26个字符

统计当前目录空间使用情况

sudo du -sh ./*

场合:ssd快要爆了,要清理一下

adb查看进程

adb shell ps

查看某个进程的内存

adb shell

dumpsys meminfo com.nxtomo.gch_hk_tw

查找并显示前10,后10

grep -A10 -B10 ‘show item’ file
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Bash Shell awk