Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to create a text file which should contain random text data that can be read by human. I know that we can use /dev/urandom and /dev/random for getting random data. But it is not readable by humans. I need to create a file which contains random text format. Is there any way to do that?

share|improve this question
    
"Readable by humans" as in making actual sense? Full sentences? Or just some dictionary words? –  slhck Dec 23 '13 at 12:13
add comment

2 Answers 2

up vote 2 down vote accepted

We can do it by following command

base64 /dev/urandom | head -c 10000000 > file.txt

It creates a file with name file.txt size of 10 MB.

share|improve this answer
    
Thanks! This works perfectly on OSX –  hanxue Jul 11 at 4:20
add comment

get the output of:

tr -dc A-Za-z0-9 </dev/urandom 

and pipe it to a file.

You can use head command with -c or -n to limit the file size

example to generate a 1kB file a.txt:

tr -dc A-Za-z0-9 </dev/urandom | head -c 1024 > a.txt
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.