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 ...
随机推荐
- javaWeb学习一
web开发(web就是网页): 静态web html.css 提供给所有人看到数据不会改变 动态web 提供给所有人看到数据会改变,不同用户.不同时间和地点都会不同 技术栈:Servlet/JSP,A ...
- webapi参数接收不到特殊字符
js前端 var uri="http://w3cschool.cc/my test.php?name=ståle&car=saab"; document.write(enc ...
- xlwings rest api
https://pbihub.cn/blog/964/created_at https://docs.xlwings.org/zh_CN/latest/rest_api.html xlwings &g ...
- datagridview 标题设置背景图片
private void dgvCaozuoList_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e. ...
- NSIS KillProcDLL插件 扩展使用
客户端插件KillProcDLL ,用于结束进程. 官网文档:https://nsis.sourceforge.io/KillProcDLL_plug-in 使用场景 卸载程序时,结束正在运行的应用程 ...
- D8-16K加密锁配置流程
1.vscode安装yttool插件,可在拓展商店中搜索ext:yt即可找到. 补充地址:https://marketplace.visualstudio.com/items?itemName=ytk ...
- 找出一组数中出现次数最多的数(csp201312-1)
问题描述:找出一组数字出现次数最多的数,如果有多个这样的数,输出其中最小的一个. 算法:sort排序,遍历数组,每遍历一个数,查出它已经出现的次数. 代码: #include<bits/stdc ...
- Window 连接linux系统上的Redis
windows 设置连接linux redis 一.查看linux 6379端口是否开发 firewall-cmd --query-port=6379/tcp 如果返回no则端口没有开启 fire ...
- K8S详细教程
Kubernetes详细教程 1. Kubernetes介绍 1.1 应用部署方式演变 在部署应用程序的方式上,主要经历了三个时代: 传统部署:互联网早期,会直接将应用程序部署在物理机上 优点:简单, ...
- react 二级路由嵌套
嵌套路由之后,静态文静路径错误, 更改webpack 打包output 输出根目录,publicPath:'/',二级路由刷新之后白屏,在首页模板文件中路径前加 /,