1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
1. ifconfig | grep Bcast| grep 192| awk '{print $2}' | sed 's/addr://g'
2. ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | awk -F: '{print $2}'
3. ifconfig eth0 | grep Bcast | awk '{print $2}' | awk -F: '{print $2}'
-F: 表示以:号分隔。 获取MAC地址: ifconfig eth0 | grep HWaddr | awk '{print $5}'
顺便记得一个测试命令: test $ test -d /root #检测是否有/root目录
$ echo $? #检测上一条命令是否执成功。0 为成功,非0不成功
test 命令可以简写成 [ -d /root ] #注意加空格
test 命令常用的几个参数:
-d 测试目录是否存在 -e 测试文件是否存在,包括块文件,设备文件等 -f 测试文件是否为普通 |
本文转自笔下生辉 51CTO博客,原文链接:http://blog.51cto.com/752030200/1844985,如需转载请自行联系原作者