#!/bin/csh -f # cprm # ------------------------------------------------------------------------------ # Shell script to copy a file and then delete the original, instead of moving # it, as a way to update the timestamp so it will be backed up by incremental # backup software. Also creates the nested target directories to contain # the new copy, if necessary. # ------------------------------------------------------------------------------ # Usage: See Usage section below or run with no arguments to see usage. # Assumptions: # Effects: # - Copies a file and deletes the original. # Notes: # Implementation Notes: # Portability Issues: # Revision History: # $Log$ # ------------------------------------------------------------------------------ set option = if ("$1" == "-i") then set option = "$1" shift endif if ($#argv != 2) then echo "Usage: $0:t [-i] source_filename target_filename_or_existing_dir" exit 1 endif set rc = 1 if (! -e $1:q) then echo -n "mdcp: $1:q"; echo ": No such file" else if (! -f $1:q) then echo -n "mdcp: $1:q"; echo ": Must be a plain file, not a link or directory" else if (! -r $1:q) then echo -n "mdcp: $1:q"; echo ": Must not be read-protected" else # Use :q instead of "" in case option is empty. Generates nothing instead # of an empty quoted string which would be counted as first arg. mdcp $option:q $1:q $2:q set rc = $status if ($rc == 0) then rm -v $option:q $1:q set rc = $status endif endif exit $rc