beanshell脚本构造生成随机大小的文件
文件下载地址:链接: https://pan.baidu.com/s/1wum8hfBeLMipdtQlqysp8A?pwd=8e7r 提取码: 8e7r
#!/bin/bash -e
# sh filerandomsize.sh /opt/xntest/1MB ftp_file_1M_10090917.txt 1 M 1000
# sh filerandomsize.sh /opt/xntest/100MB ftp_file_100M_10090917.txt 100 M 100
# sh filerandomsize.sh /opt/xntest/1GB ftp_file_1g_10090917.txt 1024 M 10
# sh filerandomsize.sh /opt/xntest/10GB ftp_file_10g_10090917.txt 10240 M 2
out_file_path=$1
out_file_name=$2
file_size=$3
size_unit=$4
file_count=$5
tmp_out_file_name=$out_file_name.tmp
function check_input_param()
{
if [[ "a" == "a"$out_file_name || "a" == "a"$file_size || "a" == "a"$size_unit ]]; then
echo "Error param input !"
echo "Type in like this: $0 [out-file-name] [file-szie] [size-unit]"
echo "param list as follow:"
echo "[out-file-name]: input your output file name, Relative path and absolute path are OK."
echo "[file-size]: The file size of output file, which must be an integer."
echo "[size-unit]: Only support K/M/G. They mean xxxKB/xxxMB/xxxGB."
exit
fi
}
function check_file_size_if_integer()
{
if [ -n "$file_size" -a "$file_size" = "${file_size//[^0-9]/}" ]; then
echo "file_size=$file_size"
else
echo "[file-size] error: The file size of output file, which must be an integer."
exit
fi
}
function check_file_count_if_integer()
{
if [ -n "$file_count" -a "$file_count" = "${file_count//[^0-9]/}" ]; then
echo "file_count=$file_count"
else
echo "[file-count] error: The file count of output file, which must be an integer."
exit
fi
}
function check_size_unit()
{
if [[ "K" != $size_unit && "M" != $size_unit && "G" != $size_unit ]]; then
echo "[size-unit] error: Only support K/M/G. They mean xxxKB/xxxMB/xxxGB."
exit
fi
}
function create_random_file()
{
dd if=/dev/urandom of=$tmp_out_file_name oflag=direct bs=1$size_unit count=$file_size conv=notrunc
mv $tmp_out_file_name $out_file_name
}
check_input_param
check_file_size_if_integer
check_file_count_if_integer
check_size_unit
create_random_file
if ((file_count>1));then
for ((i=1;i<=file_count;i++))
do
#out_file_name="$file_name-multiple-$i.txt"
echo "yes|cp -rf $out_file_name $out_file_path/multiple-$i-$out_file_name"
yes|cp -rf $out_file_name "$out_file_path/multiple-$i-$out_file_name"
done
echo "$file_count files created: $out_file_path"
else
echo "$out_file_path$out_file_name"
yes|cp -rf $out_file_name $out_file_path
echo "1 file created: $out_file_path"
fi
beanshell脚本构造生成随机大小的文件的更多相关文章
- linux和window下生成任意大小的文件
在Windows环境下的实现方法 使用fsutil命令,在windows xp和win 7下应该都自带了这个命令.命令的格式是 fsutil file createnew 新文件名 文件大小.例如 ...
- linux生成指定大小的文件(转)
# dd if=/dev/zero of=50M.file bs=1M count=50在当前目录下生成一个50M的文件 虚拟块设备文件更通用的名称是硬盘镜像文件(Hard Disk Image),但 ...
- 【Linux】生成任意大小的文件
有时候,我们需要生成指定大小的随机文件,比如在学习过程中使用的测试文件. 命令: Linux:/qinys # dd if=/dev/zero of=tmp.data bs=500k count=1 ...
- Linux shell 脚本攻略之生成任意大小的文件
摘自:<Linux shell 脚本攻略>
- java生成随机大数据文件
package iie.udps.test; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutput ...
- linux shell 脚本攻略学习10--生成任意大小的文件和文本文件的交集与差集详解
一.生成任意大小的文件(dd命令): 举例: amosli@amosli-pc:~/learn/example$ ; + records in + records out bytes ( MB/s a ...
- Windows下创建指定大小的文件
前言 因为需要测试存储容量,所以需要能生成指定大小的文件. 执行 #语法:fsutil file createnew 路径和文件名 文件大小 fsutil file createnew D:\test ...
- 生成随机验证码,上传图片文件,解析HTML
1.生成随机图片验证码 1.1 页面调用createvalidatecode 生成随机图片验证码方法: <div class="inputLine"><label ...
- dd 生成指定大小文件
d命令可以轻易实现创建指定大小的文件,如 dd if=/dev/zero of=test bs=1M count=1000 会生成一个1000M的test文件,文件内容为全0(因从/dev/zero中 ...
- PHP 生成指定大小随机图片
PHP 生成指定大小随机图片 <?php $image_width = 100; $image_height = 100; $image_str = ''; if (isset($_GET['w ...
随机推荐
- Linux的终端(base),进入base环境
正常界面,如下 带有(base) 一般是由于安装了conda环境管理软件,它自带一个base环境.第一次安装时出现这种情况可能是由于软件将启动base环境的命令写入-/.bashrc 文件,这就相当于 ...
- 前端js下载excel
// 1.文件流下载文件: export function axiosPostExport(url, data, fileName, suffix = '.xlsx') { url = get ...
- Eclipse git提交代码 覆盖问题
创建本地分支 拉取远程分支到本地 进行代码更新 然后 commit 然后将本地代码推送到远程分支 再发起合入请求 使用elipse 提交合入代码时, 注意push 提交远程分支时, 选择中 要选 ...
- python 操作配置文件(configparser模块)
用于生成和修改常见配置文档,当前模块的名称在 python 3.x 版本中变更为 configparser 配置文件信息: [DEFAULT] ServerAliveInterval = 45 Com ...
- (前端面试题)详解 JS 的 setTimeout 和 setInterval 两大定时器
程序员面试题库分享 1.前端面试题库 (面试必备) 推荐:★★★★★ 地址:前端面试题库 2.前端技术导航大全 推荐:★★★★★ 地址:前端技术导航大全 3.开发者颜色 ...
- vue3中reactive数据被重新赋值后无法双向绑定,使用reactive包裹数组如何正确赋值?
需求:将接口请求到的列表数据赋值给响应数据arr const arr = reactive([]); const load = () => { const res = [2, 3, 4, 5]; ...
- springboot配置ssl变成https证书
前段时间跳槽了,疫情期间啥也干,回想了这个项目当中的一些新接触的东西记下来,为了方便以后自己看,也给新手提供以下便利.如果这边篇随笔能够给你带来便利,小衲不胜荣幸,如果有错误也欢迎批评指正,大家共同学 ...
- 以EEPROM为例的硬件IIC的使用
目录 参考调试MPU6050与EEPROM的经验,整合了目标内存/寄存器地址是否为16位的情况,合并了单字节与多字节间的操作,添加了返回值与读写超时功能:硬件IIC的7位从机地址查询方式读写参考代码 ...
- Selenium无浏览器页面执行测试用例—静默执行
在执行WebUI自动化用例的时候,经常需要不打开浏览器执行自动化测试,这时就需要用到浏览器的静默执行.浏览器静默执行要点:1.定义Chrome的选项,两种方式任选 chrome_options = w ...
- Python的入门复习一 Day 8——from“夜曲编程”
Day 8 time: 2021.8.5. 原来P课程已经安排好了专题复习呢.所以,今天的重心就落在了角落知识点于相关课程实践上了.这次总结,也是一如既往地兵分两路呢. 注意事项: 格式化时,在前,引 ...