文件下载地址:链接: 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脚本构造生成随机大小的文件的更多相关文章

  1. linux和window下生成任意大小的文件

    在Windows环境下的实现方法   使用fsutil命令,在windows xp和win 7下应该都自带了这个命令.命令的格式是 fsutil file createnew 新文件名 文件大小.例如 ...

  2. linux生成指定大小的文件(转)

    # dd if=/dev/zero of=50M.file bs=1M count=50在当前目录下生成一个50M的文件 虚拟块设备文件更通用的名称是硬盘镜像文件(Hard Disk Image),但 ...

  3. 【Linux】生成任意大小的文件

    有时候,我们需要生成指定大小的随机文件,比如在学习过程中使用的测试文件. 命令: Linux:/qinys # dd if=/dev/zero of=tmp.data bs=500k count=1 ...

  4. Linux shell 脚本攻略之生成任意大小的文件

    摘自:<Linux shell 脚本攻略>

  5. java生成随机大数据文件

    package iie.udps.test; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutput ...

  6. linux shell 脚本攻略学习10--生成任意大小的文件和文本文件的交集与差集详解

    一.生成任意大小的文件(dd命令): 举例: amosli@amosli-pc:~/learn/example$ ; + records in + records out bytes ( MB/s a ...

  7. Windows下创建指定大小的文件

    前言 因为需要测试存储容量,所以需要能生成指定大小的文件. 执行 #语法:fsutil file createnew 路径和文件名 文件大小 fsutil file createnew D:\test ...

  8. 生成随机验证码,上传图片文件,解析HTML

    1.生成随机图片验证码 1.1 页面调用createvalidatecode 生成随机图片验证码方法: <div class="inputLine"><label ...

  9. dd 生成指定大小文件

    d命令可以轻易实现创建指定大小的文件,如 dd if=/dev/zero of=test bs=1M count=1000 会生成一个1000M的test文件,文件内容为全0(因从/dev/zero中 ...

  10. PHP 生成指定大小随机图片

    PHP 生成指定大小随机图片 <?php $image_width = 100; $image_height = 100; $image_str = ''; if (isset($_GET['w ...

随机推荐

  1. [引擎开发] 深入GPU和渲染优化(基础篇)

    https://blog.csdn.net/ZJU_fish1996/article/details/109269448

  2. Mogeaver 连接数据库

    下载安装Mogeaver是一款开源软件,下载地址如下:https://docs.mogdb.io/zh/mogdb/v3.0/mogeaver-release-notes 根据您的操作系统选择相应的安 ...

  3. 安装完IDEA后无法打开

    安装完IDEA后无法打开 一.现象 安装完IDEA2021.3版本后,无论用什么办法都无法打开 二.原因 原先有安装过idea,里面有加载过一些插件,或者是破解过,会生成一些文件,导致IDEA无法运行 ...

  4. python ddt file_data

    # -*- coding: utf-8 -*-"""------------------------------------------------- File Name ...

  5. Java面向对象之什么是面向对象?

    面向过程 & 面向对象 面向过程思想 1.步骤清晰简单,第一步做什么,第二步做什么...... 2.面对过程适合处理一些较为简单的问题 面向对象思想 1.物以类聚,分类的思想模式,思考问题首先 ...

  6. java 导入Excel数据校验判断哪行那列

    记录工作 需求是导入数据的时候需要判断哪一行是空行,或者哪一行超过限制字符,然后返回给前端做展示 @PostMapping("/importExcel") @ApiOperatio ...

  7. SAR成像(六):距离徙动矫正

    1.什么是距离徙动? 距离徙动产生原因是合成孔径雷达的运动平台与目标之间的相对运动.对于地面一静止的点目标,当它处于雷达波束照射范围内的时间中时,随着飞行载体的运动,它与雷达飞行载体之间的距离会不断的 ...

  8. css节流

    众所周知,函数节流(throttle)是 JS 中一个非常常见的优化手段,可以有效避免函数过于频繁的执行. 举个例子:一个保存按钮,为了避免重复提交或者服务器考虑,往往需要对点击行为做一定的限制,比如 ...

  9. Experience Cloud

    通过Apex的方式上传 Topic: String communityId = [Select Id from Network where Name = 'MobileMNOCS'].Id; Inte ...

  10. 067_VFPage中Js与controller交互方式(二) RemoteAction

    上篇文章介绍了Toolkit API,是一种js的前台写法 同步调用格式:sforce.connection.method("argument1","argument2& ...