Sample data and how to produce them

Sometimes a programmer needs to test/debug one application by feeding it with data, random or not. In a situation like this, there are some utilities one can use to produce as many data as she needs.

Let’s start with a simple example of feeding our test application (we will call it “test_data”) with zeroes, say 100 bytes with a value of zero.

head –bytes=100 /dev/zero | ./test_data

The above command has two parts; the first one (before the ‘|’ delimiter), ‘head‘, reads /dev/zero device, which provides us with zero-valued bytes as a stream, up to a count of 100 bytes and sends them to the second one, ‘test_data‘, as input. If we wanted more, say 100 KBytes, we would replace the parameter of ‘bytes’ argument with “100k”, as follows: