1

I need to find test binary data for the command xxd -ps file which is some GB or at least several MBs. I am using at the moment /usr/bin/telnet but it is not big and heterogenous between different OS.

Which file is big and sufficient homogenous between different operating systems?

  • 2
    I doubt you will find any file of that size which is identical in various operating system. What about generating one yourself from /dev/random and distributing it to all systems involved? Or (if distribution is not possible) use a short shell/perl/ruby script to generate the identical file on various systems? – nohillside Jun 26 '15 at 9:24
  • @patrix How can you use this /dev/random? The point is just to get something big and passing it to xxd -ps such that I can simulate parallel programming processes. – Léo Léopold Hertz 준영 Jun 26 '15 at 9:39
  • 2
    see superuser.com/questions/470949/…, the openssl way will work as well – nohillside Jun 26 '15 at 9:57
2

Answer from Patrix's link here.

dd

To create binary file of 1GB by

dd if=/dev/urandom of=sample.bin bs=64m count=16

giving

enter image description here

which is preferred by the linked answer but is slow with records in my Macbook Air mid-2013 on Yosemite 10.10.3 1073741824 bytes (1.1 GB) copied, 116.436 s, 9.2 MB/s.

openssl

The following command is faster but does not create a binary file

openssl rand -out sample.txt -base64 $(( 2**30 * 3/4 ))

giving

head sample.txt
3WqdfYDB8XejIk2VzdsLJ8SuxNhH/oCJ8mKXbrsVmT5uZaCGmW7YZN3PAbY9lVqc
0Tr2sX4RXlJ5PUzujJ2SUf/xjI3peTlpEYTnxJKiDS4CDo+TBskVBgiE2/J8+9Cy
CcSnkkuHLJgTCxqj9tYB3e3bkzIMu6LvcvjUQR2p8IYl7zBLG+fyYZvHsKT85XVV
NaDKbCQ3xLLAXXd2mtIHpjgEDuvrMrTXEJpvgSveBJteyw27FRjwNA+kG5cdgFbd
rIZORF4HT4fBiPdwOQ8+bWn0qR4xugLC+RNjMH8MCBSb4QiEGisEigZxezqnUYlv
mZAs9afD0H5UpXHMU75jcyWzEgrJPj6L0uVyFuR59mFI2mNGqW2P926rifd2j1Da
ETvnT/5KybfjSfanpLmbaEbb4CjRW056ZCeZnp4oWiwFBmajGdwFiOXOtCnDn2El
YWaNK0a8LwrLMNKCbjk+rlpy/3MRm50DAcAR6UwDbAPcusEcNtfDJxdon3/HZfFy
Z4kp9VhUfhqVibcf5LwYhOa3bfLVwIPRZDKrP5cv0vNBz0ajB9MGnTaDSeDLgzRs
L5ayb2H6s02HAR+ilRQkOxpXYetaqMVMHuI1mIO0yvbLZdq1FmtTAN3rRXdn0ENN

or

xxd sample.txt | head -10
0000000: 3357 7164 6659 4442 3858 656a 496b 3256  3WqdfYDB8XejIk2V
0000010: 7a64 734c 4a38 5375 784e 6848 2f6f 434a  zdsLJ8SuxNhH/oCJ
0000020: 386d 4b58 6272 7356 6d54 3575 5a61 4347  8mKXbrsVmT5uZaCG
0000030: 6d57 3759 5a4e 3350 4162 5939 6c56 7163  mW7YZN3PAbY9lVqc
0000040: 0a30 5472 3273 5834 5258 6c4a 3550 557a  .0Tr2sX4RXlJ5PUz
0000050: 756a 4a32 5355 662f 786a 4933 7065 546c  ujJ2SUf/xjI3peTl
0000060: 7045 5954 6e78 4a4b 6944 5334 4344 6f2b  pEYTnxJKiDS4CDo+
0000070: 5442 736b 5642 6769 4532 2f4a 382b 3943  TBskVBgiE2/J8+9C
0000080: 790a 4363 536e 6b6b 7548 4c4a 6754 4378  y.CcSnkkuHLJgTCx
0000090: 716a 3974 5942 3365 3362 6b7a 494d 7536  qj9tYB3e3bkzIMu6

Or you run

openssl rand -out sample.bin $(( 2**30 * 3/4 )) 

which does create a file using the full byte range

xxd sample.bin | head -10
0000000: 9084 48bf dc6c 21d3 579f 6153 6b3d e62f  ..H..l!.W.aSk=./
0000010: 9460 0228 5e1e b531 3bb4 223a 120b 0273  .`.(^..1;.":...s
0000020: 27e2 de7c b9e8 63b8 6333 9702 05cc 2fe1  '..|..c.c3..../.
0000030: 5aab fed9 1732 246d 59c8 de14 6b04 907d  Z....2$mY...k..}
0000040: f164 81c4 7065 9798 71b7 891b dbe1 f06b  .d..pe..q......k
0000050: 24ad 9749 b596 4dad a4a9 b415 64a7 6ccb  $..I..M.....d.l.
0000060: 8463 a125 9abe 9a7b 7f70 f3ea 9acf 1eb0  .c.%...{.p......
0000070: ebe0 9f0d 87dd ffce 4e20 9793 eda8 1872  ........N .....r
0000080: f08a 3aa3 d3e7 5bca 6b84 b44d 1650 4b9e  ..:...[.k..M.PK.
0000090: 282f c9c3 1e8c b423 472e 857c 134e 18ca  (/.....#G..|.N..
  • @patrix Can you run dd with base64? I did not intend to skip it. – Léo Léopold Hertz 준영 Jun 26 '15 at 18:08
  • man dd is your friend here – nohillside Jun 26 '15 at 18:10
  • I have it correctly bs=64m but it still in binary. – Léo Léopold Hertz 준영 Jun 26 '15 at 18:11
  • 1
    bs is the block size. There is no option in dd to convert a random byte stream into printable characters (you can convert to/from EBCDIC though, if you ever need to get data from/to an IBM mainframe system). – nohillside Jun 26 '15 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .