How to create multiple files with random data with bash

前端 未结 3 1409

How do I create multiple files (More than 20k, I need these files to run a test for syncying) with random data in OS X? I used a previously answered question (How Can I Create

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 13:21

    You can do it with a shell for loop:

    for i in {1..20000}; do dd if=/dev/urandom bs=1 count=1 of=file$i; done
    

    Adjust count and bs as necessary to make files of the size you care about. Note that I changed to /dev/urandom to prevent blocking.

    You can add some >/dev/null 2>&1 to quiet it down, too.

提交回复
热议问题