#! /bin/sh # 11. Write a shell script to take a file name on its command line, and # edit it with sed so that every instance of "/usr/local/bin" is # changed to "/usr/bin" # This solution suffers from a number of problems. # 1. If it is interrupted, then a temporary file may be left behind # 2. The file permissions and ownership of the original file may be changed # 3. The tmpfile location is known and can be used to attack the user. prog=$(basename $0) usage() { cat < $tmpfile mv $tmpfile $file || echo "Unable to overwrite $file" done