I want to create a file of a specific size containing only printable strings in bash.
My first thought was to use /dev/urandom:
dd if=/d
You can use one of the following:
truncate
You should have a baseline textfile with a size larger than what you need.
then use the following:
truncate -s 5M filename
DESCRIPTION
Shrink or extend the size of each FILE to the specified size
[...]
-s, --size=SIZE
set or adjust the file size by SIZE
2.Use tail: this options requires reference text file too.
tail -c 1MB reference_big.txt> 1mb.txt