jerrys@truevision.com (Jerry Schwartz) (06/06/91)
Is there any way to have a backup of the file you are editing saved automatically with vi. I tried set directory, but that only saves it while the session is open. Jerry Schwartz jjs@epicb.truevision.com P.S. I know that Tom can answer this one.
rock@warp.Eng.Sun.COM (Bill Petro) (06/06/91)
jerrys@truevision.com (Jerry Schwartz) writes: >Is there any way to have a backup of the file you are >editing saved automatically with vi. I tried set directory, but >that only saves it while the session is open. > Jerry Schwartz > jjs@epicb.truevision.com >P.S. I know that Tom can answer this one. Here is "vv" that makes a backup file for you. #!/bin/sh if test -z "$FAVEDITOR"; then FAVEDITOR=/usr/ucb/vi fi case $# in 0) $FAVEEDITOR # no file, invoke editor w/o arg exit;; 1) EDITFIL=$1;; *) echo "Usage: vv [editfile]" exit 1;; esac EDITERR=editerr TEMPFIL=/tmp/`logname`.$$ if test -r $EDITFIL; then cp $EDITFIL $TEMPFIL if $FAVEDITOR $EDITFIL; then mv $TEMPFIL ${EDITFIL}.bak echo "Backup file created" else mv $TEMPFIL $EDITERR echo edit error: original file is in $EDITERR fi else $FAVEDITOR $EDITFIL fi -- Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock "UNIX for the sake of the kingdom of heaven" Matthew 19:12