Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2326699
  • 博文数量: 145
  • 博客积分: 8668
  • 博客等级: 中将
  • 技术积分: 3922
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-09 21:21
个人简介

work hard

文章分类

全部博文(145)

文章存档

2016年(1)

2015年(1)

2014年(1)

2013年(12)

2012年(3)

2011年(9)

2010年(34)

2009年(55)

2008年(20)

2007年(9)

分类:

2010-04-05 15:48:08

浅析sh脚本中cat <<_ACEOF
和cat >>confdefs.h <<_ACEOF语句原理

1.批量打印字符串到terminal,直到遇到字符串'_ACEOF'结束,将把字符串一起送到cat打印到terminal上
  cat <<_ACEOF //将以字符串形式打印到terminal上,$HOME等宏展开依然有效[luther.gliethttp]
  --bindir=DIR           user executables [EPREFIX/bin]
  ...
  --psdir=DIR            ps documentation [DOCDIR]
_ACEOF

  cat <<\_ACEOF//续行,表示如下_ACEOF区间中的字符串和上面的_ACEOF从逻辑上为一体.

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
_ACEOF          //本段字符串显示结束

看看实验:
luther@gliethttp:~$ cat <> gliethttp
> ni hao a
> shi de
> an hen hao
>
> luther
gliethttp
ni hao a
shi de
an hen hao

luther@gliethttp:~$ cat <<\luther//直到遇到luther字符串,才将数据一起送到cat显示
> nihaoa
> gliethttp
> yes
> byebye
> luther
nihaoa
gliethttp
yes
byebye
luther@gliethttp:~$
2.向文件追加内容,一直遇到字符串'_ACEOF'为止,追加内容结束.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
看看实例:
luther@gliethttp:~$ cat >>luther.h <<_ACEOF //向文件luther.h添加内容,如果luther.h文件不存在,那么创建之
> #define luther_gliethttp  INT_MAX
> 哈哈哈哈
> 中国人民抖精神
> _ACEOF
luther@gliethttp:~$ cat luther.h
#define luther_gliethttp  INT_MAX
哈哈哈哈
中国人民抖精神
luther@gliethttp:~$ cat >>luther.h <<_ACEOF //追加
> aaaa
> bbbbb
> cccc
> _ACEOF
luther@gliethttp:~$ cat luther.h
#define luther_gliethttp  INT_MAX
哈哈哈哈
中国人民抖精神
aaaa
bbbbb
cccc
luther@gliethttp:~$ cat >luther.h <<_ACEOF //使用>符号,先清除luther.h中的原有内容,然后添加如下_ACEOF之前的字符串
> aaa
> bbb
> ccc
> _ACEOF
luther@gliethttp:~$ cat luther.h
aaa
bbb
ccc
luther@gliethttp:~$
阅读(11904) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~