- 论坛徽章:
- 0
|
#!/bin/bash
ssh -p65422 192.168.1.129 <<EOF
ip a
echo "_______________________________________"
ip a | grep "inet " | grep -v "127.0.0.1" | sed 's/^ //g' | awk '{print $2}'
EOF
执行结果:
[root@shell ~]# sh -x test23.sh
+ ssh -p22 -t 192.168.16.238
Pseudo-terminal will not be allocated because stdin is not a terminal.
Address 192.168.16.238 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:4c:ad:9f brd ff:ff:ff:ff:ff:ff
inet 192.168.16.238/24 brd 192.168.16.255 scope global eth0
-----------------------------------------------------------------
inet 192.168.16.238/24 brd 192.168.16.255 scope global eth0
可以看到上面的sed 生效了,awk没有执行,为什么??
[root@oracle10g ~]# ip a | grep "inet " | grep -v "127.0.0.1" | sed 's/^ //g' | /bin/awk '{print $2}'
192.168.16.238/24
命令本身没有问题~~
|
|