If you just want to re-create the /dev/zero
abilities but with a character other than zero/null, you can use tr
to change all the zero's ("\000" in octal) into something else.
So to spit out an endless stream of "a"s for example, you could do:
cat /dev/zero | tr "\000" "\141" | head -c 20
aaaaaaaaaaaaaaaaaaaa
Or skip the cat and output an M's worth (1024*1024) with
head -c 1M /dev/zero |tr "\000" "\141"
"\141" being the "a" character.
See this site http://www.asciitable.com/ for a quick short page of ASCII - Octal codes. It's actually this image here:
![enter image description here](../../I/static/images/42d2449f86657153b5fbc4f0c75a9f27f720d9021ab8a2407dfb8cc6bd976db7.gif)
(I know, old "solved" question, but I found it while searching for an endless stream of different characters, so this "solves" the "how to make /dev/one or /dev/[different character]" problem.)
They're implemented in the kernel. Look at
zero_lseek
,read_zero
,write_zero
,mmap_zero
indrivers/char/mem.c
. – David Schwartz – 2012-10-01T07:04:49.167Oh…so I would have to modify the kernel? – Blacklight Shining – 2012-10-01T07:07:42.873
3Not necessarily, it depends on precisely what you want to do. Most likely, you would at least need to implement a module. – David Schwartz – 2012-10-01T07:18:04.853
What about
/dev/one
? – Blacklight Shining – 2012-10-01T07:45:12.267