Suppose I want to create, in the spirit of /dev/zero, a file /dev/seven that produces the character '7' whenever it is read from. How should I go about doing something like this? Would I need to modify the kernel?
About Unix standard multi-key support If a character is unavailable on the keyboard, you can insert the character by pressing the special Compose key followed by a sequence of two other keys. See the table below for the keys used to insert various characters. Note that in Amaya you can change the order of the two keys.
Explanation. Double your \ , like this: \\ , so that your shell does not interpret the backslashes from your filename as escape characters. Escape " and ' , like this: \" , \' , so that your shell interprets the double quotes as part of the filename.
$@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.
It turns out, $() is called a command substitution. The command in between $() or backticks (“) is run and the output replaces $() . It can also be described as executing a command inside of another command.
Yes, you'd need to create a driver for that special character device.
For linux, I'd suggest you read Linux Device Drivers by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman. (Chapter 3 talks about char drivers, but do read at least the first two chapters also.)
A device driver is not necessary, a fifo special file plus a user program generating the stream of 7
is perfectly able to provide this behavior.
You'll need about a five line shell script, all told.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With