标签:shell
此脚本的作用在每新打开一个文件,自动生成#!/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
本文出自 “11065514” 博客,请务必保留此出处http://11075514.blog.51cto.com/11065514/1865826
标签:shell
原文地址:http://11075514.blog.51cto.com/11065514/1865826