Home Create a large file with a given size with a pattern in Linux
Reply: 2

Create a large file with a given size with a pattern in Linux

katta
1#
katta Published in 2017-12-07 16:54:24Z

In Linux how can I create a large file with a given text or hex pattern (Like DEADBEEFDEADBEEFDEADBEEF ....)

I know dd can be used to create large files but it doesn't write desired text or hex pattern

dd if=/dev/urandom of=/tmp/bigfile bs=blocksize count=size

or

dd if=/dev/zero of=/tmp/bigfile bs=blocksize count=size

Quickly create a large file on a Linux system?

How to create a file with a given size in Linux?

Chirlo
2#
Chirlo Reply to 2017-12-07 17:08:13Z
while true ; do printf "DEADBEEF"; done | dd of=/tmp/bigfile bs=blocksize count=size
SriniV
3#
SriniV Reply to 2017-12-07 17:06:57Z

If your intention is to achieve a scrambled data and not random.

shuf folder/* | dd of=target.txt bs=1K count=2048

to get a 2MB sample file which you can then shorten or invoke the command above again with different numbers for count

folder/* will contain files with your patterns

Or as an alternative you can have your hexadecimal values stored in a single file in separate lines and use shuf to shuffle them based on your need and fill them

shuf -n 100 source.txt | dd of=target.txt bs=1K count=2048

Or you can just dump it in dd as

dd if=source.txt of=target.txt bs=1K count=2048

Shuffle Documentation

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.246029 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO