Chinaunix首页 | 论坛 | 博客
  • 博客访问: 797091
  • 博文数量: 120
  • 博客积分: 7531
  • 博客等级: 少将
  • 技术积分: 1253
  • 用 户 组: 普通用户
  • 注册时间: 2005-10-11 12:18
文章分类

全部博文(120)

文章存档

2013年(1)

2012年(7)

2011年(1)

2010年(7)

2009年(15)

2008年(13)

2007年(22)

2006年(45)

2005年(9)

分类: LINUX

2012-08-01 16:53:29

1、<<<是把后面的当成字符串传给前面的命令
[root@localhost tmp]# wc <<< "aaaaa"
1 1 6
[root@localhost tmp]# echo aaaaa |wc
      1       1       6
[root@localhost tmp]# echo -n "aaaaa" |wc
      0       1       5
[root@localhost tmp]#
 
2、<是把后面的当成文件传给前面的命令
[root@localhost tmp]# wc < aaaa
-bash: aaaa: No such file or directory
[root@localhost tmp]# wc
 28  28 488
 
3、<<把后面的当成一个分界符,然后从标准输入读取内容,直到遇到下一个分界符结束。
[root@localhost tmp]# wc << aaaa
> zxm
> aaaa
1 1 4
 
4、>和>>都是把前面的输出重定向到后面的文件,后面的表示追加。
[root@localhost tmp]# ls  >a.tt 
[root@localhost tmp]# ls  >>a.tt
 
5、把b.tt文件传给cat命令,把结果重定向到a.tt,整个过程相当于复制。
[root@localhost tmp]# cat a.tt
[root@localhost tmp]# cat >a.tt
 
6、重定向的举例
[root@localhost soft]# ls a.tt b.tt
ls: cannot access b.tt: No such file or directory
a.tt
[root@localhost soft]# ls a.tt b.tt >log.tt
ls: cannot access b.tt: No such file or directory
[root@localhost soft]# ls a.tt b.tt >log.tt 2>&1
[root@localhost soft]# ls a.tt b.tt &>log.tt
[root@localhost soft]# ls a.tt b.tt 2>&-
a.tt
[root@localhost soft]# ls a.tt b.tt 2>&- 1>&-
[root@localhost soft]# ls a.tt b.tt &>/dev/null
[root@localhost soft]# ls a.tt b.tt 1>&-    
ls: cannot access b.tt: No such file or directory
ls: write error: Bad file descriptor
[root@localhost soft]# 
阅读(1479) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

公子月2012-08-01 16:55:06