`
webcenterol
  • 浏览: 906743 次
文章分类
社区版块
存档分类
最新评论

为学习APUE(Unix环境高级编程)偷懒,而写的脚本,基本上相当于一个简单的工程创建脚本了

 
阅读更多
首先我单独建了一个目录用来保存学习时需要的目录,将此脚本拷贝到这个目录下面,以后每次以一个参数运行脚本,就会自动创建目录,cpp文件,makefile文件,需要做的就是进入此目录,然后修改cpp文件,然后make,enjoy it!呵呵,说实话,自从学习了bash以后,才越来越觉得linux并不是一个复杂难用的系统。

D:/ubuntu/apue/ctapue.sh.html 1 #!/usr/bin/env bash
2 dir=apue$1
3 file=${dir}/apue${1}.cpp
4 makefile=${dir}/Makefile
5
6 if[-d${dir}]
7 then
8 echo"the path ${dir}is exist."
9 exit1
10 else
11 mkdir${dir}
12 fi
13
14 # Create the src file
15 cat >${file}<<end-of-file
16 #include <stdio.h>
17 #include "../apue.h"
18
19
20 int main(int argc, char* argv[])
21 {
22
23
24 exit(0);
25 }
26
27 end-of-file
28
29 # Create the makefile
30 cat >${makefile}<<end-of-makefile
31 src=apue${1}.cpp
32 ob=test
33 /${ob} : /${src}
34 g++ -Wall -g -o /${ob} /${src}
35
36 end-of-makefile

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics