linux bashrc添加脚本,Linux实用脚本以及bashrc配置收集

#!/bin/bash

export MOL=$1

export FCHK=$2

export SUBDIR=~+

export GAUSS_SCRDIR=~/tmp/gaussian/$

export GAUSS_EXEDIR=xxxxxxxxxxxxxxxx      #写自己的gaussian路径

export USERNAME=`whoami`

if [ null$MOL == null ]; then

echo -e "\n\033[31m ************************************* \033[0m"

echo -e "\033[31m Please input the name of a .com file! \033[0m"

echo -e "\033[31m ************************************* \033[0m"

exit

fi

full=`date --rfc-2822`                           #时间这儿,这样写,适合中文系统的同学想获得英文缩写。

week=${full%,*}

submit=`date "+%Y-%m-%d, $week, %T"`

start=`date +%s`

if [ -e $SUBDIR/$MOL.com ] ; then

echo -e "\n *******************************************************"

echo " Gaussian Task:"

echo " Now calculating $SUBDIR/$MOL.com!"

echo " *******************************************************"

mkdir -p $GAUSS_SCRDIR

cd $GAUSS_SCRDIR

echo -e "\033[31m Now $SUBDIR/$MOL.com is still calculated in the background~ \033[0m"  >> ~/tmp/now.log

$GAUSS_EXEDIR/g09 $SUBDIR/$MOL.com $SUBDIR/$MOL.log

else

echo -e "\n\033[31m ************************************************************************* \033[0m"

echo -e "\033[31m Cannot find $SUBDIR/$MOL.com! Please check your PATH! \033[0m"

echo -e "\033[31m ************************************************************************* \033[0m"

exit

fi

if grep -i '%chk=' $SUBDIR/$MOL.com ; then

if [ -e *.chk ] ; then

mv -f *.chk $SUBDIR/$MOL.chk

fi

else

echo -e "\nYou didn't request the .chk file!"

fi

if [ -e *.wfx ] ; then

mv -f *.wfx $SUBDIR/$MOL.wfx

fi

if [ -e *.wfn ] ; then                                           #这部分自己想要啥文件自己加就好

mv -f *.wfn $SUBDIR/$MOL.wfn

fi

for ((k=31; k<=41; k++))

do

if [ -e *.$k ] ; then

mv -f *.$k $SUBDIR/$MOL.$k

fi

done

if [ $FCHK !="fchk" ] || [ null$2 == null ] ; then > /dev/null

echo "You didn't request to produce the .fchk file!"

else

if [ -e $SUBDIR/$MOL.chk ] ; then

formchk $SUBDIR/$MOL.chk $SUBDIR/$MOL.fchk

echo ".fchk file formed sucessfully"

else

echo "So cannot form .fchk file!"

fi

fi

rm -rf $GAUSS_SCRDIR

echo -e "\n=========================================================================="

echo "The temporary folder $GAUSS_SCRDIR of calculation was deleted"

stop=`date +%s`

time=`expr "$stop" - "$start"`

end=`date "+%Y-%m-%d, $week, %T"`

echo "**************************************************************************" >> $SUBDIR/$MOL.log

echo File: $SUBDIR/$MOL.com >> $SUBDIR/$MOL.log

if [ $time -le 60 ] ; then

echo Time consuming: $time seconds >> $SUBDIR/$MOL.log

elif [ $time -gt 60 -a $time -le 3600 ] ; then

echo "Time consuming: `echo "scale=2;$time/60"|bc` minutes" >> $SUBDIR/$MOL.log

elif [ $time -gt 3600 -a $time -le 86400 ] ; then

echo "Time consuming: `echo "scale=2;$time/3600"|bc` hours" >> $SUBDIR/$MOL.log

elif [ $time -gt 86400 ] ; then

echo "Time consuming: `echo "scale=2;$time/86400"|bc` days" >> $SUBDIR/$MOL.log

fi

echo Submission time: $submit >> $SUBDIR/$MOL.log

echo Ending time: $end >> $SUBDIR/$MOL.log

echo "**************************************************************************" >> $SUBDIR/$MOL.log

echo Temporary folder is $GAUSS_SCRDIR >> $SUBDIR/$MOL.log

echo "=========================================================================="

tail -25 $SUBDIR/$MOL.log

echo "These last 25 lines are from file: $SUBDIR/$MOL.log"

echo "=========================================================================="

echo -e "\n\033[31m ************************************************************************************** \033[0m" >> ~/tmp/results.log

echo -e "\033[31m Gaussian Task:\033[0m"                                        >> ~/tmp/results.log

grep -q "Normal termination" $SUBDIR/$MOL.log

if [ $? -eq 1 ] ; then

echo -e "\033[31m $SUBDIR/$MOL.com !!!ERROR TERMINATED!!! at $end \033[0m"      >> ~/tmp/results.log

else

echo -e "\033[31m $SUBDIR/$MOL.com !!!NORMAL TERMINATED!!! at $end \033[0m"     >> ~/tmp/results.log

fi

echo -e "\033[31m ************************************************************************************** \033[0m" >> ~/tmp/results.log

w|grep "$USERNAME"|head -n 1|sed 's/ //g' > /dev/null

if [ $? -eq 0 ] ; then

rm -f ~/tmp/results.log

fi

sed -i '/'$MOL.com'/d' ~/tmp/now.log

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值