| 1 |
#!/bin/sh |
| 2 |
############################################################################# |
| 3 |
# Author: # |
| 4 |
# ------ # |
| 5 |
# Anton Kokalj Email: [email protected] # |
| 6 |
# Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 # |
| 7 |
# Jozef Stefan Institute Fax: x 386 1 477 3811 # |
| 8 |
# Jamova 39, SI-1000 Ljubljana # |
| 9 |
# SLOVENIA # |
| 10 |
# # |
| 11 |
# Source: $XCRYSDEN_TOPDIR/scripts/xc_cleanscratch |
| 12 |
# ------ # |
| 13 |
# Copyright (c) 1996-2003 by Anton Kokalj # |
| 14 |
############################################################################# |
| 15 |
|
| 16 |
if test "x$XCRYSDEN_SCRATCH" = "x"; then |
| 17 |
echo "Exiting; XCRYSDEN_SCRATCH does not exists !!!" |
| 18 |
exit 0 |
| 19 |
fi |
| 20 |
|
| 21 |
DELETE_FILES=$XCRYSDEN_SCRATCH/xc_* |
| 22 |
|
| 23 |
Question () { |
| 24 |
echo " |
| 25 |
XCRYSDEN_SCRATCH directory: $XCRYSDEN_SCRATCH/ will be cleaned |
| 26 |
(i.e. rm -rf $DELETE_FILES). |
| 27 |
|
| 28 |
The following files/directories will be deleted: |
| 29 |
" |
| 30 |
files=`ls $XCRYSDEN_SCRATCH/* 2> /dev/null` |
| 31 |
if [ "$files" = "" ]; then |
| 32 |
echo " XCRYSDEN_SCRATCH directory is empty !!! |
| 33 |
" |
| 34 |
exit |
| 35 |
fi |
| 36 |
|
| 37 |
echo "$files" | grep xc_ |
| 38 |
|
| 39 |
$ECHO_n " |
| 40 |
Really delete? ([yes]/[n]o) " |
| 41 |
read ans |
| 42 |
|
| 43 |
if [ \( x"$ans" != x"yes" \) -a \( x"$ans" != x"n" \) ]; then |
| 44 |
echo " |
| 45 |
-- Please answer yes or n !!!" |
| 46 |
Question |
| 47 |
fi |
| 48 |
} |
| 49 |
|
| 50 |
# |
| 51 |
# assuming user shell is csh or tcsh or sh |
| 52 |
# |
| 53 |
if [ "`echo -n a`" = "-n a" ]; then |
| 54 |
ECHO_n=echo |
| 55 |
else |
| 56 |
ECHO_n="echo -n" |
| 57 |
fi |
| 58 |
|
| 59 |
Question |
| 60 |
|
| 61 |
if [ "$ans" = yes ]; then |
| 62 |
$ECHO_n " |
| 63 |
Deleting $DELETE_FILES ... " |
| 64 |
cd $XCRYSDEN_SCRATCH/ |
| 65 |
rm -rf xc_* |
| 66 |
echo "OK |
| 67 |
" |
| 68 |
fi |