码迷,mamicode.com
首页 > 其他好文 > 详细

创建 cpp 脚本

时间:2015-05-20 02:16:19      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:创建 cpp 脚本

str=$1
f()
{
    echo "#include <stdio.h>" > $str
    echo "#include <stdlib.h>" >> $str
    echo "#include <string.h>" >> $str
    echo "#include <unistd.h>" >> $str
    echo "#include <ctype.h>" >> $str
    echo "#include <stdlib.h>" >> $str
    echo "#include <dirent.h>" >> $str
    echo "#include <time.h>" >> $str
    echo "#include <sys/types.h>" >> $str
    echo "#include <errno.h>"  >> $str
    echo "#include <string>" >> $str
    echo "#include <vector>" >> $str
    echo "#include <map>" >> $str
    echo "#include <iostream>" >> $str
    echo "" >> $str
    echo "using namespace std;" >> $str
    echo "" >> $str
    echo "int main(int argc,char *argv[])" >> $str
    echo "{" >> $str
    echo "" >> $str
    echo "  cout<<\"hello world\"<<endl;" >>$str
    echo "" >> $str
    echo "  return 0;" >> $str
    echo "}" >> $str
}
if [ $# != 1 ]
then 
    echo "请输入 文件名"
elif [ -f $str ]
    then
        echo "文件已经存在 ! [ $str ]"
elif [ ${str##*.} != "cpp" ]
    then
        echo "请检查文件类型 是否为cpp文件 [${str##*.}]"
else
    f;
    vi $str
fi

保存为 crcpp | chmod a+x crcpp |crcpp a.cpp

创建 cpp 脚本

标签:创建 cpp 脚本

原文地址:http://ayang.blog.51cto.com/4224455/1652897

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!