Skip to content

Commit

Permalink
replace test with bash's pattern substitution
Browse files Browse the repository at this point in the history
and test if the value is an integer value.
  • Loading branch information
frederic-mahe committed Jun 16, 2020
1 parent 9c8890a commit ba477fa
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Scripts/whats_new.sh
@@ -1,14 +1,8 @@
#!/bin/bash

# test for input
# TODO: validate integer value to set input
if [ -z "$1" ]
then
# Modified time in days:
mdays=2
else
mdays="$1"
fi
mdays=${1:-2} # default value is 2 days
(( mdays >= 1 && mdays <= 100 )) || {echo "Error: non-integer value" ; exit 1 ;}

mhours=$(($mdays * 24))

Expand All @@ -27,4 +21,4 @@ find /media/fat/ -mtime -$mdays -iname "*rbf"|\
echo " -" `dirname "$rbf"| sed 's/\/media\/fat\///g'` : `basename $rbf` "["`date +"%a, %b %d" -r "$rbf"`"]"
done


exit 0

0 comments on commit ba477fa

Please sign in to comment.