Here is a nice trick on how to create a dummy character text file consisting of any chosen or random characters. In the first example we will create and simple file consisting of a single character X with a size of 1000 bytes:
$  < /dev/urandom tr -dc "X" | head -c1000 > file.txt
SAMPLE:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
or we can create a file consisting of an alphabetic and numeric character:
$ < /dev/urandom tr -dc "[:alnum:]" | head -c1000 > file.txt
SAMPLE:
CCjeuAhJNc4yxBfeMbbYX1U1TnSCVS5oiV53MtGoA6s45FAw9H9PyfZJHrA421

Let's add some TABs and spaces and new line characters:
$ < /dev/urandom tr -dc "\t\n [:alnum:]" | head -c1000 > file.txt
SAMPLE:
AKelkoPRzlQK9MKO3xzpcfpnbnxNqkBlyn0YfsDZne1 V iZRU5J
iKuahZjmeEeTutFQH4ex7UdMmVxxRrqDmiMosdeTmu	g0sjFIZb
Jox0IXZZGZ2 WSG7pYjpop5AB1gUGAcoJxuTlX
In the last example we will create a random text file of 1000000000 bytes containing any characters, tabs and new lines:
$ < /dev/urandom tr -dc "[:space:][:print:]" | head -c1000000000 > file
SAMPLE:
*)d
   qTND;k$=2h#eSY[Cu
l1w:M,|.&x}Jzla<rS.=@<Xmd9;Fc

@PPD'$I4j?OBk yOP|tEGjr`?B~IT
8pgr$Tpj3mj6v
             $?:OZw.%h`7s7G4iXDN
Here is how the file looks under the od microscope:
$ od -a file
0000000   *   )   d  vt   q   T   N   D   ;   k   $   =   2   h   #   e
0000020   S   Y   [   C   u  nl   m   n   6   .   y   I   |   .   &   x
0000040   }   J   z   l   a   <   r   S   .   =   @   <   X   m   d   9
0000060   ;   F   c  cr   l   1   w   :   M   ,  nl  vt   @   P   P   D
0000100   '   $   I   4   j   ?   O   B   k  sp   y   O   P   |   t   E
0000120   G   j   r   `   ?   B   ~   I   T  nl   8   p   g   r   $   T
0000140   p   j   3   m   j   6   v  vt   $   ?   :   O   Z   w   .   %
0000160   h   `   7   s   7   G   4   i   X   D   N  ff   0   d   h   g
0000200   *   N   u   &   (   9   u   (   v   I   n   T   -   J   z   ;
0000220   2   v   U   L   :   s   X   a   {   )   s   W   U   s   H   5
0000240   b   D   >   9   Q  sp   #   &   q   w   H   S   [   C   {  vt
0000260  sp  cr   H   (   N   ;   5   <   g   $  ht   0  nl   @   5   O
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions