shell之一些测试脚本
# !/bin/bash
dir=$ for file in `ls $dir`
do
if [ -d $dir/$file ]
then
echo $file is dir
else
time=`stat $file | tail - | head - | cut -d' ' -f2- | cut -d. -f1`
name=$file
currentTime=`date "+%Y-%m-%d %H:%M:%S"`
echo "$name $time $currentTime"
oldtime=`date +%s -d "$time"`
newtime=`date +%s -d "$currentTime"`
# echo $(($newtime-$oldtime))
if [ $(($oldtime-$newtime)) -ge ]
then
echo "$file is a new file"
else
echo "$file not modify"
fi
fi
done
#!/bin/bash
#echo $#
if [ $# -eq 1 ]
then
nums=$
# echo $nums
for((i=;i<$nums;i++))
do
#sleep 1
touch ./file-`date +%F-%H-%M-%S`-$i.txt
done else
echo "you need input nums like ./app nums,bye"
exit -
fi
# !/bin/bash
dir=$ for file in `ls $dir`
do
if [ -d $dir/$file ]
then
echo $file is dir
else
file=$dir/$file
#获取最后修改时间,并截取成 y-m-d h:m:s
time=`stat -c %y $file | cut -d. -f1`
name=$file
currentTime=`date "+%Y-%m-%d %H:%M:%S"`
echo "$name $time $currentTime"
#将字符串时间转换成数字,距1970年的时间
#文件当前的最后修改时间
oldtime=`date +%s -d "$time"`
#系统当前时间
newtime=`date +%s -d "$currentTime"`
#时间偏移量,这里定义为一天24*60*60,意味着一天扫描一次,如需修改扫描次数,修改这个地方就行
shifttime=
#这里用当前文件最后修改时间,与一天前的时刻做比较,如果大于0,说明文件在从昨天这个时刻到今天这个时刻之间发生了变化,偏移量不是一天时,代表的是这段时间内
#测试 shifttime=600 10分钟
#shifttime=600
if [ $(($oldtime-$newtime+$shifttime)) -ge ]
then
echo "$file is a new file"
else
echo "$file not modify"
fi
fi
done
#!/bin/bash
USER_IP=`who -u am i >/dev/null | awk '{print $NF}' | sed -e 's/[()]//g'`
HISTDIR=/usr/share/.history
if [ -z $USER_IP ]
then
USER_IP=`hostname`
fi
if [ ! -d $HISTDIR ]
then
mkdir -p $HISTDIR
chmod $HISTDIR
fi if [ ! -d $HISTDIR/${LOGNAME} ]
then
mkdir -p $HISTDIR/${LOGNAME}
chmod $HISTDIR/${LOGNAME}
fi export HISTSIZE=
DT=`date +%Y%m%d_%H%M%S`
export HISTFILE="$HISTDIR/${LOGNAME}/${USER_IP}.history.$DT"
export HISTTIMEFORMAT="[%Y.%m.%d %H:%M:%S]"
chmod $HISTDIR/${LOGNAME}/*.history.* >/dev/null
捕获信号
#!/bin/bash trap "echo sigint" SIGINT
echo "This is a test program"
count=
while [ $count -le ]
do
echo "Loop #$count"
sleep
count=$[ $count + ]
done
echo "This is the end of the test program"
read使用
#!/bin/bash #simple read
echo -n "Enter your name:"
read name
echo "Hello $name,welcome!" #read 指定
read -p "Please enter your age:" age
days=$[ $age * ]
echo "That makes you over $days days old" #read 不带变量,存在默认变量REPLY中
read -p "Please enter your age:"
echo "your age is $REPLY" #read 延时选项
read -t -p "Please enter your age:"
echo "your age is $REPLY" #read 默读
read -s -p "Please enter your passwd:"
echo "your passwd is $REPLY" read读文件
#!/bin/bash #read file if [ $# -lt 1 ]
then
echo "Usage ./readfile.sh testfile"
exit -
fi echo "file name is $1" count=
cat $ | while read line
do
echo "Line $count:$line"
count=$[ $count+ ]
done
echo "Finished processing the file"
打开文件
--------------------------------------------------------------------------------
#!/bin/bash #open
exec > test
echo "This is a test line of data" >&
#close
exec >&-
echo "This won't work" >&
shell之一些测试脚本的更多相关文章
- Linux CAN Shell 测试脚本程序
2012-01-13 22:57:14 为我的开发板2440做二次开发,添加了can驱动,做了驱动测试程序,没理由不添加一个测试脚本程序啊!修改了测试程序,使应用程序更加灵活,添加了一下传递参数.接着 ...
- shell编程之服务脚本编写,文件锁以及信号捕获
shell脚本编程是linux运维工程师必备的技能,也是非常重要的一个技能,所以把shell编程学好,只有好处.基础语法我也就不讲了,学过C语言这些语言的,稍微看一下就能明白shell编程的基础,所以 ...
- Linux shell编写端口扫描脚本
Linux shell编写端口扫描脚本 需求: 扫描特定主机 扫描特定主机的特定端口 扫描特定网段 扫描特定网段中哪些主机开放了特定的端口 源码如下: #/bin/bash #该脚本用于对特定目标主机 ...
- Appium环境的安装与配置,Python测试脚本测试
Appium自动化测试系列1 - Appium环境的安装与配置 发表于4个月前(2015-01-27 14:34) 阅读(803) | 评论(0) 0人收藏此文章, 我要收藏 赞0 寻找 会’偷懒 ...
- shell编写一个判断脚本
shell编写一个判断脚本 4.1问题 本例要求在虚拟机server0上创建/roo ...
- SPF邮件伪造漏洞测试脚本
测试脚本: # -*- coding: utf-8 -*- import socket,select,base64,os,re,time,datetime class mail: def __init ...
- Shell文件权限和脚本执行
一.预备知识 1.shell的作用 2.常识 (1)Tab键自动补全 使用Terminal时,输入命令的前几个字母,敲tab会自动补全命令或文件名.目录等. 好处:操作速度更快:不容易出错: ...
- 用BlazeMeter录制JMeter测试脚本
工具: 1,JMeter 2,Chrome 3,BlazeMeter 4,SwitchyOmega(如果需要代理) 步骤: 以上工具准备好以后就可以录制JMeter的测试脚本了, 在Chrome中点击 ...
- Loadrunner开发测试脚本
Loadrunner开发测试脚本 开发测试脚本可以通过录制,也可以手动开发,建议能录制的尽量录制,省时省力,不能录制的只能费力自己开发了,具体看项目情况来决定. 使用Loadrunner开发脚本过程中 ...
随机推荐
- logistic regression (逻辑回归) 概述
:http://hi.baidu.com/hehehehello/blog/item/0b59cd803bf15ece9023d96e.html#send http://en.wikipedia.or ...
- CUDA线性内存分配
原文链接 概述:线性存储器可以通过cudaMalloc().cudaMallocPitch()和cudaMalloc3D()分配 1.1D线性内存分配 1 cudaMalloc(void**,int) ...
- visual attention
The visual attention mechanism may have at least the following basic components [Tsotsos, et. al. 19 ...
- ssm整合-错误3
1.警告: Unknown version string [3.1]. Default version will be used. 因为Tomcat版本为7,支持3.1版本的为Tomcat 8: 2. ...
- spring-bean(xml方式管理)
特点 每一次加载XML文件时候,都会将配置文件中包含的配置实例化. ID与name区别:name不是唯一的,但是可以使用特殊字符 Class:生成类的实例 Bean的作用域: 三种实例化方式 类的构造 ...
- ES6笔记03-Set和Map数据结构
ES6提供了新的数据结构Set.它类似于数组,但是成员的值都是唯一的,没有重复的值.Set本身是一个构造函数,用来生成Set数据结构. var s = new Set(); [2, 3, 5, 4, ...
- sql常用函数instr()和substr()
Decode decode(条件,值1,翻译值1,值2,翻译值2,...,缺省值) 该函数与程序中的 If...else if...else 意义一样 NVL 格式:NVL( string1, rep ...
- scrapy--cnblogs
之前一直在学习关于滑块验证码的爬虫知识,最接近的当属于模拟人的行为进行鼠标移动,登录页面之后在获取了,由于一直找不到滑块验证码的原图,无法通过openCV获取当前滑块所需要移动的距离. 1.机智如我开 ...
- 字符串的输入问题 C++
C++中,初学时最常用的输入字符的方式为cin,但是,cin是如何确定已经完成了字符串的输入了呢?由于不能通过键盘输入空字符("\0"),因此cin需要用别的方法来确定字符串的结尾 ...
- 图像的模糊-opencv
调用两个API,一个是均值模糊,一个是高斯模糊.如下所示: #include<opencv2/opencv.hpp> #include<iostream> using name ...