LoginSignup
1
1

More than 5 years have passed since last update.

linux: { 100KBのファイルを作る > head -c 100K /dev/urandom > test.txt } | bash: { 100K_0001.datと200K_0001.datの作成 }

Last updated at Posted at 2017-10-13
動作環境
Windows 7 Pro (32bit)
SmartGit Version 17.0.4 #10132
SmartGit付属のMinGW32
grep (GNU grep) 2.24
head (GNU coreutils) 8.25

100KBファイル作成

C++ Builderのソフト実装用にダミーデータ作成を検討中。

MinGW32では以下のコマンドが使えた。

$head -c 100K /dev/urandom > test.txt

参考: http://kazmax.zpp.jp/linux/random_file.html by kazmaxさん

bash: 100K_0001.datと200K_0001.datの作成

関連: bash > print > "00001"という書式での標準出力

mkdmy_171013_exec
#!/bin/bash

for siz in "100K" "200K";do
for idx in $(seq 1 3);do
    wrk=$(printf "%05d\n" $idx)
    head -c $siz /dev/urandom > ${siz}_${wrk}.dat
done
done

上記をMinGW32から実行すると、そのフォルダに以下のファイルが生成される。

100K_00001.dat
100K_00002.dat
100K_00003.dat
200K_00001.dat
200K_00002.dat
200K_00003.dat

100K_*.dat : 100KBのファイル
200K_*.dat : 200KBのファイル

200Kを200にすると200バイトのファイルを生成できる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1