Chinaunix首页 | 论坛 | 博客
  • 博客访问: 936419
  • 博文数量: 192
  • 博客积分: 3070
  • 博客等级: 中校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-27 23:44
个人简介

Start Linux Leave Linux a while Back to Linux

文章分类

全部博文(192)

文章存档

2023年(18)

2022年(11)

2021年(8)

2020年(14)

2019年(7)

2018年(13)

2017年(16)

2016年(4)

2012年(2)

2011年(13)

2010年(26)

2009年(13)

2008年(27)

2007年(20)

我的朋友

分类:

2011-05-26 10:08:37

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/\/.*$//' 删除从 / 开始到结尾的字符串








阅读(1202) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~