2015-10-16

[SOLVED]Linux create million of files

#/opt/script/mil-of-files.sh
#KET QUA CHINH XAC DEN PHAN NGHIN GIAY
####################
now="$(date +'%Y.%m.%d-%H.%M.%S.%3N')"
now1="$(date +'%Y.%m.%d-%H.%M.%S.%3N')"
start_ts="$(date +'%s%3N')"
#############COMMAND:BEGIN
#http://www.heatware.net/linux-unix/create-large-many-number-files-thousands-millions/
mkdir -p /opt/sync
cd /opt/sync
#Create 500.000 files, 50K
#==>Total size: 23.84185791015625 GB
#Details:
#500000 x 50 = 25,000,000
dd if=/dev/zero of=masterfile bs=1 count=25000000

#The -b option specifies the size in bytes of each file. The -a option defines the length of the filename of the new files +1 (-a 10 means create a 11 character long filename)
split -b 5120 -a 20 Empire.Of.Lust.2014.720p.WEB-DL.H264-REALHD.mp4
#Empire.Of.Lust.2014.720p.WEB-DL.H264-REALHD.mp4    2,715,813,981    23/04/2015 01:28a    ra--
#5120 bytes/1 files
#Độ dài file: 20 ký tự
#Các file nhỏ được tạo ra bằng cách chia nhỏ nội dung file "Empire.Of.Lust.2014.720p.WEB-DL.H264-REALHD.mp4"
#Tổng số file được tạo ra: 530.435 files

#############COMMAND:END

now2="$(date +'%Y.%m.%d-%H.%M.%S.%3N')"
stop_ts="$(date +'%s%3N')"
DIFF=$((stop_ts-start_ts))
hour=$((DIFF/(60*60*1000)))
min=$((DIFF/(60*1000)))
sec=$(((DIFF%(60*1000))/1000))
ms=$(((DIFF%(60*1000))%1000))
echo "####################################"
echo "**RUNTIME**|[""${hour}:${min}:${sec}.$ms""](h:m:s:msec)"
echo "STARTING...|"$now1
echo "...... DONE|"$now2
echo "####################################"

#RESULT:
# ####################################
# **RUNTIME**|[0:1:26.501](h:m:s:msec)
# STARTING...|2015.09.25-14.08.01.327
# ...... DONE|2015.09.25-14.09.27.828
# ####################################

No comments:

Post a Comment