[wangshumin@CentOSNode3 shell]$ df -h /
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 17G 6.1G 11G 36% /
[wangshumin@CentOSNode3 shell]$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 17G 6.1G 11G 36% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 492M 0 492M 0% /dev/shm
tmpfs 492M 7.2M 485M 2% /run
tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/sda1 1014M 194M 821M 20% /boot
tmpfs 99M 12K 99M 1% /run/user/42
tmpfs 99M 0 99M 0% /run/user/1000
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot"
/dev/sda1 1014M 194M 821M 20% /boot
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $6}'
/boot
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $5}'
20%
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1
20
[wangshumin@CentOSNode3 shell]$ v=df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1
bash: -h: 未找到命令...
[wangshumin@CentOSNode3 shell]$ v=(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1)
-bash: 未预期的符号 `|' 附近有语法错误
[wangshumin@CentOSNode3 shell]$ v=(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1 )
-bash: 未预期的符号 `|' 附近有语法错误
[wangshumin@CentOSNode3 shell]$ v=$(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1 )
[wangshumin@CentOSNode3 shell]$ echo $v
20
[wangshumin@CentOSNode3 shell]$ netstat -tnlu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:40579 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}'
(only
Local
0.0.0.0:111
192.168.122.1:53
0.0.0.0:22
127.0.0.1:631
127.0.0.1:25
:::111
:::22
::1:631
::1:25
192.168.122.1:53
0.0.0.0:67
0.0.0.0:40579
0.0.0.0:5353
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}' | grep ":80$"
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}' | grep ":25$"
127.0.0.1:25
::1:25
[wangshumin@CentOSNode3 shell]$ v2=$(netstat -tnlu | awk '{print $4}' | grep ":25$")
[wangshumin@CentOSNode3 shell]$ echo v2
v2
[wangshumin@CentOSNode3 shell]$ echo $v2
127.0.0.1:25 ::1:25
[wangshumin@CentOSNode3 shell]$ v2=$(netstat -tnlu | awk '{print $4}' | grep "0.1:25$")
[wangshumin@CentOSNode3 shell]$ echo $v2
127.0.0.1:25
[wangshumin@CentOSNode3 shell]$
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 17G 6.1G 11G 36% /
[wangshumin@CentOSNode3 shell]$ df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 17G 6.1G 11G 36% /
devtmpfs 478M 0 478M 0% /dev
tmpfs 492M 0 492M 0% /dev/shm
tmpfs 492M 7.2M 485M 2% /run
tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/sda1 1014M 194M 821M 20% /boot
tmpfs 99M 12K 99M 1% /run/user/42
tmpfs 99M 0 99M 0% /run/user/1000
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot"
/dev/sda1 1014M 194M 821M 20% /boot
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $6}'
/boot
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $5}'
20%
[wangshumin@CentOSNode3 shell]$ df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1
20
[wangshumin@CentOSNode3 shell]$ v=df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1
bash: -h: 未找到命令...
[wangshumin@CentOSNode3 shell]$ v=(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1)
-bash: 未预期的符号 `|' 附近有语法错误
[wangshumin@CentOSNode3 shell]$ v=(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1 )
-bash: 未预期的符号 `|' 附近有语法错误
[wangshumin@CentOSNode3 shell]$ v=$(df -h | grep "/boot" | awk '{print $5}' | cut -d "%" -f 1 )
[wangshumin@CentOSNode3 shell]$ echo $v
20
[wangshumin@CentOSNode3 shell]$ netstat -tnlu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
udp 0 0 192.168.122.1:53 0.0.0.0:*
udp 0 0 0.0.0.0:67 0.0.0.0:*
udp 0 0 0.0.0.0:40579 0.0.0.0:*
udp 0 0 0.0.0.0:5353 0.0.0.0:*
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}'
(only
Local
0.0.0.0:111
192.168.122.1:53
0.0.0.0:22
127.0.0.1:631
127.0.0.1:25
:::111
:::22
::1:631
::1:25
192.168.122.1:53
0.0.0.0:67
0.0.0.0:40579
0.0.0.0:5353
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}' | grep ":80$"
[wangshumin@CentOSNode3 shell]$ netstat -tnlu | awk '{print $4}' | grep ":25$"
127.0.0.1:25
::1:25
[wangshumin@CentOSNode3 shell]$ v2=$(netstat -tnlu | awk '{print $4}' | grep ":25$")
[wangshumin@CentOSNode3 shell]$ echo v2
v2
[wangshumin@CentOSNode3 shell]$ echo $v2
127.0.0.1:25 ::1:25
[wangshumin@CentOSNode3 shell]$ v2=$(netstat -tnlu | awk '{print $4}' | grep "0.1:25$")
[wangshumin@CentOSNode3 shell]$ echo $v2
127.0.0.1:25
[wangshumin@CentOSNode3 shell]$