PROJET AUTOBLOG


Shaarli - Librement Shaarli

Site original : Shaarli - Librement Shaarli

⇐ retour index

How to create a large number of files in Linux (thousands or millions)

mardi 24 avril 2018 à 11:57
How to create the master file

    Determine the number of files and the size of each file that you require
    Multiply the total number of files times the size (in bytes). For example: If you want to create 10000 files that are 10 bytes each, do 10000 * 10 = 1,000,000. This represents the size of the master file that is needed.
    To create this master file, run the command:

    dd if=/dev/zero of=masterfile bs=1 count=1000000
    The above command will create a 1 MB file called ‘masterfile’. This file contains all 0’s. If you would like it to contain random binary data, use /dev/urandom

To split the master file into thousands of pieces

    Now that the master file is created, you can now use this to generate the desired 10,000 files that are 10 bytes each.
    Run the command:

    split -b 10 -a 10 masterfile
Permalink