局域网中分了很多网段,而IP地址使用情况也未知,前期也没有规划和记录,当新的主机需要使用固定IP的时候,能否第一时间知道哪个IP空闲就显得很重要了,如果一个一个去ping的话太浪费时间. 这里分享一个shell脚本检测当前哪些IP在用和不在用. 脚本如下: #!/bin/bash #先生成一个网段的IP文本 ippre="192.168.10." for i in {1..254} do echo "${ippre}$i" >>ip.txt done #…
方法1: if grep -qs '/mnt/foo' /proc/mounts; then echo "It's mounted." else echo "It's not mounted." fi 方法2: if mountpoint -q /mnt/foo then echo "mounted" else echo "not mounted" fi…
<1> d211 admin # for i in {3..254} ; do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive ;done192.168.1.5 is alive192.168.1.7 is alive <2> fping -a -g 192.168.5.1 192.168.5.177 -s -n >lele.txt -a Show system…
本文用于记录学习和日常中使用过的shell脚本 [脚本1]打印形状 打印等腰三角形.直角三角形.倒直角三角形.菱形 #!/bin/bash # 等腰三角形 read -p "Please input the length: " n for i in `seq 1 $n` do for ((j=$n;j>i;j--)) do echo -n " " done for m in `seq 1 $i` do echo -n "* " done e…
shell是一种程序设计语言,是访问操作系统内核的服务. Linux的shell种类常见的有: Bourne Shell(/usr/bin/sh或/bin/sh) Bourne Again Shell(/bin/bash) C Shell(/usr/bin/csh) K Shell(/usr/bin/ksh) Shell for Root(/sbin/sh) Shell脚本执行的两种方法 ./shell.sh 根据shell脚本第一行指定的shell执行 /bin/sh test.sh 根据命令…