摘要:
1. $# 传递到脚本的参数个数 2. $* 以一个单字符串显示所有向脚本传递的参数变量。与位置变量不同,此选项参数可超过9个 3. $$ 脚本运行的当前进程ID号 4. $! 后台运行的最后一个进程的进程ID号 5. $@ 与$#相同,但是使用时加引号,并在引号中返回每个参数 6. $- 显示sh 阅读全文
posted @ 2020-09-01 11:00
chengxuyonghu
阅读(468)
评论(0)
推荐(0)
摘要:
root@test ~]# ping 192.168.2.1 -c 10 | awk '{ print $0"\t" strftime("%H:%M:%S",systime()) } 'PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data. 10:3 阅读全文
posted @ 2020-09-01 09:18
chengxuyonghu
阅读(1663)
评论(0)
推荐(0)
摘要:
shell中截取字符串的方法有很多中, ${expression}一共有9种使用方法。 ${parameter:-word} ${parameter:=word} ${parameter:?word} ${parameter:+word} 上面4种可以用来进行缺省值的替换。 ${#parameter 阅读全文
posted @ 2020-09-01 09:15
chengxuyonghu
阅读(525)
评论(0)
推荐(0)
摘要:
shell脚本实现将文件中的几行输出合并成一行显示 现在有一个文件aa.txt ,其实现格式如下,而我想实现的结果是192.168.1.17 down [root@localhost shell]# cat aa.txt192.168.1.17down192.168.1.103open192.168 阅读全文
posted @ 2020-09-01 09:12
chengxuyonghu
阅读(1219)
评论(0)
推荐(0)
摘要:
#!/usr/bin/env bash #输入参数 1=年份 2=开始月份 3=结束月份 for i in `seq -w $2 $3`; do #参数1为指定的年份 year=$1 echo $year monthday=${year}${i}01 echo $monthday #产生每月第一天 阅读全文
posted @ 2020-09-01 09:10
chengxuyonghu
阅读(859)
评论(0)
推荐(0)
摘要:
shell版本#!/bin/bashfor i in `cat /home/haoren/iplist20171214.txt`do (sleep 1;)|telnet $i 80 2>&1 |grep "Connected to $ip$i">/dev/null 2>&1 if [ $? == 0 阅读全文
posted @ 2020-09-01 09:09
chengxuyonghu
阅读(171)
评论(0)
推荐(0)
浙公网安备 33010602011771号