Using cw adds write permission; c-w takes it away. This is the single script file for all three commands:
#! /bin/sh case "$0" in *cx) chmod +x "$@" ;; *cw) chmod +w "$@" ;; *c-w) chmod -w "$@" ;; *) echo "$0: Help! Shouldn't get here!" 1>&2; exit 1 ;; esac
The script has three links. Put it in a file named cx. Then type:
chmod +x cx%
ln cx cw%
ln cx c-w
The script tests the name it was called with, in
$0, to decide
which chmod command to run.
This trick saves disk space.
You can add other commands, too, by adding a line to the case
and another link.
|22.9 Protect Important Files: Make Them Unwritable||22.11 A Loophole: Modifying Files Without Write Access|