1) 获取IP地址
#mount
/dev/sdb8 on / type ext4 (rw,errors=remount-ro,commit=0)
proc on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
none on /dev type devtmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
/home/ken_lu/.Private on /home/ken_lu type ecryptfs (ecryptfs_sig=5dba0ddbd06c40cf,ecryptfs_fnek_sig=1083ef649ce2e10c,ecryptfs_cipher=aes,ecryptfs_key_bytes=16)
gvfs-fuse-daemon on /home/ken_lu/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=ken_lu)
//192.168.13.233/project/SVN/Android/ on /mnt/svn type cifs (rw,mand)
#mount | grep "/mnt/svn" | sed 's/\/\///' | awk '{print $1}' | sed 's/\/.*$//'
192.168.13.233
#cat getipaddr
#!/bin/bash
IPADDR=$(mount | grep "/mnt/svn" | sed 's/\/\///' | awk '{print $1}' | sed 's/\/.*$//')
echo -n "IP Address is: "
echo $IPADDR
#./getipaddr
IP Address is: 192.168.13.233
-------------------------------------------------
说明:
#mount | grep "/mnt/svn"
//192.168.13.233/project/SVN/Android/ on /mnt/svn type cifs (rw,mand)
#mount | grep "/mnt/svn" | sed 's/\/\///'
192.168.13.233/project/SVN/Android/ on /mnt/svn type cifs (rw,mand)
将 "//" 替换为空(须加反斜杠)
#mount | grep "/mnt/svn" | sed 's/\/\///' | awk '{print $1}'
192.168.13.233/project/SVN/Android/
打印第一字段(以空格分割)
#mount | grep "/mnt/svn" | sed 's/\/\///' | awk '{print $1}' | sed 's/\/.*$//')
192.168.13.233
sed 's/\/.*$//' 删除从 / 开始到结尾的字符串
阅读(1246) | 评论(0) | 转发(0) |