bin sh-t file OPT_T false OPT_V false OPT_N false SN while getopts tvn

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/sh-t file 3 4
#
OPT_T=false
OPT_V=false
OPT_N=false
SN=0
#
while getopts tvn OPTIONS
do
case $OPTIONS in
t)
OPT_T=true
SN=`expr $SN + 1`
;;
n)
OPT_N=true
SN=`expr $SN + 1`
;;
v)
OPT_V=true
SN=`expr $SN + 1`
;;
esac
done
#
while [ $SN -gt 0 ]
do
shift
SN=`expr $SN - 1`
done
#
FP=$1
FP=${FP:="NULL"}
if [ $FP = "NULL" ]
then
echo -n "Please, enter prefix of name of file: "
read FP
fi
#
#!!!!!!!! Assful Check
#expr $FN + 1 3>&4
MINSZ=$2
MINSZ=${MINSZ:="NULL"}
if [ $MINSZ = "NULL" ]
then
echo -n "Please, enter minimal size of file: "
read MINSZ
fi
#
MAXSZ=$3
MAXSZ=${MAXSZ:="NULL"}
if [ $MAXSZ = "NULL" ]
then
echo -n "Please, enter maximal size of file: "
read MAXSZ
fi
#
for CF in `wc -c $FP* | awk '{print $2}'`
do
if [ $CF != 'total' ]
then
FSZ=`wc -c $CF | awk '{print $1}'`
if [ "$FSZ" -le "$MAXSZ" ] && [ "$FSZ" -ge "$MINSZ" ]
then
rm $CF
fi
fi
done
#
OPT_T=false
OPT_V=false
OPT_N=false
SN=0
echo $OPTIONS
while getopts tvn OPTIONS
do
case $OPTIONS in
t)
OPT_T=true
SN=`expr $SN + 1`
;;
n)
OPT_N=true
SN=`expr $SN + 1`
;;
v)
OPT_V=true
SN=`expr $SN + 1`
;;
esac
done
while [ $SN -gt 0 ]
do
shift
SN=`expr $SN - 1`
done
FN=$1
FN=${FN:="NULL"}
if [ $FN = "NULL" ]
then
echo -n "Please, enter name of file: "
read FN
fi
#
Assful Check
expr $FN + 1 3>&4
#
PF=$2
PF=${PF:="NULL"}
if [ $PF = "NULL" ]
then
echo -n "Please, enter postfix of first copie: "
read PF
fi
#
LE=$3
LE=${LE:="NULL"}
if [ $LE = "NULL" ]
then
echo -n "Please, enter the number of copies: "
read LE
fi
#
LI="1"
while [ "$LI" -le "$LE" ]
do
cp $FN "${FN}${PF}"
PF=`echo $PF | tr '1-9a-zA-Y' '2-9a-zA-Z'`
LI=`expr $LI + 1`
done
#
exit 0