Creating Dummy Files with a specified size under Linux

07 09 2009
Today I was asked how to automatically create multiple non-empty dummy files under linux with just one command. Here is a small bash script. To adjust the number of files to be created, adjust the "10" in "$(seq 0 10)" to a number of your choice. To adjust the file size to be created, change "count=2" to anything you like. The "bs" parameter defines the base for the count parameter. bs=1024 means that 1024 bytes * "count" is the file size. In this case it's 2kilobyte. To have 1MB files you could either write "bs=1024 count=1024" or "bs=$((1024*1024)) count=2" or "bs=1024 count=$((1024*1))".



PS: there seems to be a problem with the bash highlighter of dp.SyntaxHighlighter: on line 4 the first "if" after dd is one if too much. The line should be "dd if=/dev/zero of=file${i} bs=1024 count=2 2>&1;"

Bookmark Creating Dummy Files with a specified size under Linux  at del.icio.us Digg Creating Dummy Files with a specified size under Linux Mixx Creating Dummy Files with a specified size under Linux Bloglines Creating Dummy Files with a specified size under Linux Technorati Creating Dummy Files with a specified size under Linux Bookmark Creating Dummy Files with a specified size under Linux  at Furl.net Bookmark Creating Dummy Files with a specified size under Linux  at blogmarks Bookmark Creating Dummy Files with a specified size under Linux  at Ma.gnolia.com wong it! Stumble It!