此脚本的作用在每新打开一个文件,自动生成#!/bin/bash解释器,当前编辑时间以及字符编码

#!/bin/bash


if [ $# -lt 1 ];then

   echo "$0 newfilename"

   exit

fi


for i in `seq $#`

do

  a=2

  file=$1

  num=`echo "${file}" | awk '{print length()}'`

  let num1=$num-$a 


  if [ -f ${file} ];then

     vi ${file}

  else

     if [[ `echo ${file:$num1:$num}` = "sh" ]];then

        echo -e "#!/bin/bash\n# current time:`date "+%Y-%m-%d %H:%M:%S\nLANG=en_US.UTF-8"`\n" >> $file

        vi $file

     else

        vi $file

     fi

  fi

shift

done