fix error for option -f
rewrite shell script