#!/bin/bash # This is a script for afet # check the number of argument if [ $# -ne 1 ]; then echo "" echo " ./run_afet.sh [input file]" echo "" exit 1 fi # check the existence of files if [ ! -f ./$1 ]; then echo "" printf " Input file \"%s\" does not exist!\n" $1 echo "" exit 1 fi echo "=============================================" printf " Input file is \"%s\"\n" $1 data_num=0 dir=$(printf "data%03d" $data_num) while [ -d "./$dir" ] do data_num=$(($data_num + 1)) dir=$(printf "data%03d" $data_num) done mkdir ${dir} cp $1 ./$dir # copy of input file printf " \"%s\" was made.\n" $dir printf " \"%s\" was copied to the directory.\n" $1 # run afet cd $dir echo "" echo " run afet" echo "=============================================" ../afet ./$1 > log.txt