我在网上查到用如下语句可以获取主机ip地址 grep `hostname` /etc/hosts| awk '{print $1}' 但我把这条语句写到脚本里,就报错 脚本: root@:/script>more ll.sh ipip=`grep `hostname` /etc/hosts| awk '{print $1}'` echo ${ipip} 报错: usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list... [-f pattern_file...] [file...] usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...] -f pa...
by erin_lyj - Shell - 2007-08-12 16:38:28 阅读(16570) 回复(10)
该语句可以获取客户端ip地址,但有时返回多个ip地址,或返回空值,可能写成多行语句就没问题,但因编程序的需要,又必须写成一行。有哪位高手解答一二? who -x|grep `who -m|awk '{print $2}` |awk '{print $6}'
请教 在unix shell中如何获取本机ip地址 【注 我的/etc/host中主机ip地址对应的名称不是固定的或者说是不知到的,并不是通常的localhost】
请教 在unix shell中如何获取本机ip地址 【注 我的/etc/host中主机ip地址对应的名称不是固定的或者说是不知到的,并不是通常的localhost】
///
#!/bin/sh FILE=/home/ip_apnic rm -f $FILE rm -f CNC rm -f OTHER rm -f CHINANET rm -f CRTC wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O $FILE grep 'apnic|CN|ipv4|' $FILE | cut -f 4,5 -d'|'|sed -e 's/|/ /g' | while read ip cnt do mask=$(cat << EOF | bc | tail -1 pow=32; define log2(x) { if (x<=1) return (pow); pow--; return(log2(x/2)); } log2($cnt) EOF) echo $ip/...
怎么用shell 修改ip呢 ---------- 思路有呢: 用 echo -------------------- 问题来了:1。怎么自选网卡 2。就是键盘键入信息怎么写进网卡 那位高手 指点一下!
solaris 10 finger -f dpcds ??? pts/14 5:14 Thu 09:16 10.101.2.35 CustomsAdmin ??? pts/2 52 Tue 13:26 10.101.2.91 CustomsAdmin ??? pts/11 Thu 14:26 10.101.2.91 CustomsAdmin ??? pts/12 2:07 Thu 12:02 10.101.2.91 CustomsAdmin ??? pts/15 ...