我常用的小shell

星期五, 07月 4th, 2008 Posted in shell, 系统管理 | No Comments »

下面是我平常用的一些bash shell 组合,方便我的日常管理。 清除所有arp 缓存 arp -n|awk '/^[1-9]/ {print "arp -d "$1}'|sh 显示打开连接数前10个机子的IP 和连接数 cat /proc/net/ip_conntrack | cut -d ' ' -f 10 | cut -d '=' -f 2 | sort | uniq -c ... Read more..

几个有用的bash shell组合

星期五, 03月 7th, 2008 Posted in shell | No Comments »

ps aux | awk '{ if ($3 > 8 ) print $2}' 这个是列出cpu 占有率高于 8% 的进程的PID cat /proc/net/arp | awk '{print $4 $1}' >>/etc/ethers 读取当前机器arp 表并把得到的mac 地址和相应的ip 地址添加到/etc/ethers 文件中去 Read more..

Bash的输入输出重定向

星期一, 03月 3rd, 2008 Posted in shell | No Comments »

使用Bash可以方便的用<和>实现输出输入的重定向,本文讨论重定向的一些细节和技巧。本文介绍部分是对Bash Quick Reference相关内容的翻译。 基础知识 文件描述符(File Descriptor),用一个数字(通常为0-9 Read more..