Hello,
I would like to control and check the right parameters
$1 must have 4 alphabetics digits among eora qora pora fora
$2 must have 2 numerics digits 00 to 11
$3 must have 2 numerics digits 00 to 59
$4 must have 10 characters alpha numerics as 2013-02-26
For example :
In case 5) if i launch my script with these parameters
./my_script dora 09 30 2013-02-26
The first parameter dora is bad, i would like that the script returns "The first parameter dora is bad"
and so on.
Can you give me some advices ?
Thank you
#!/bin/bash
# set -vx
f1() {
echo $1 $2 $3 $4 # put your function here
}
case $# in
0) echo -e "# comment1\n# comment2" > list_file # create list_file as desired
read -p "Please fill in this list_file: " # prompt as desired, read answer
echo $REPLY # do whatever with the user's reply
;;
1) [ -f "$1" ] || exit # check if file exists; otherwise exit
grep -v '^#' "$1" | # do what you did before
while read arg1 arg2 arg3 arg4
do f1 $arg1 $arg2 $arg3 $arg4
done
;;
4) echo -e "# comment1\n# comment2" > list_file # create list_file as desired
echo $1 $2 $3 $4 >> list_file # put your function here
;;
5) echo -e "# comment1\n# comment2" > $1 # create file with $1 file name as desired
shift
f1 $1 $2 $3 $4 >> "$1" # put your function here
;;
*) echo "error msg"; exit
esac