Your Ad Here

Sabtu, 23 Juli 2011

Unix Tip: SAVE A COPY

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3452 - July 23, 2011

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


SAVE A COPY

Ever edited a file, then wished
you'd saved a copy first?

This script will save it for you.
It even handles multiple files,
and multiple edits of the same file.

############### Cut here ##########
#!/bin/ksh
# My vi : Save a backup of the file(s) to edit
for file in $* ; do
if [[ -a $file ]] ; then
basefile=`basename $file`
cp $file ~/bak/${basefile}.`date +%C%y%m%d%H%M%S`
fi
done
/usr/bin/vi $*
############### Cut here ##########

You'll need to create a directory
called 'bak' in your $HOME directory,
and it would be a good idea to set up
a cron job to clear out old copies
periodically.


This tip generously supported by:
gordon.morrison@vf.vodafone.co.uk


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Tidak ada komentar:

Posting Komentar

Your Ad Here
Free Automatic Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink