Mike McCarty wrote:
# echo 59 > /proc/sys/vm/swappiness
which is what I took him to mean, as well.
I don't understand why echo should be able to write a file that
an editor cannot.
<pedantic mode>
In the above context, "echo" does not edit the file, the shell does.
When you redirect output with the '>' or '>>' operators, the shell opens
the file to the right of the operator and attaches it to the stdout file
descriptor before it launches the command to the left of the operator.
That's why the command:
$ sudo echo 59 > /proc/sys/vm/swappiness
.. doesn't work. Although "echo" would run as the root user, the shell
that the hypothetical user is running is not. Because it's the shell's
job to open /proc/sys/vm/swappiness before running "sudo", the attempt
to modify the file will fail.
I just thought I'd toss that in to the conversation. :)
</pedantic>