为生存而奔跑

   :: 首页 :: 联系 :: 聚合  :: 管理
  271 Posts :: 0 Stories :: 58 Comments :: 0 Trackbacks

留言簿(5)

我参与的团队

搜索

  •  

积分与排名

  • 积分 - 319831
  • 排名 - 75

最新评论

阅读排行榜

评论排行榜

可以在shell脚本中使用管道或者重定向输出结果。可以通过在done命令的末尾添加处理命令来实现

for file in /home/rich/*
do
   if [ -d  "$file" ]
      then
         echo "$file is a directory"
   elif
         echo "$file is a file"
   fi
done > output.txt

这样,就把for命令的结果重定向到文件output.txt中。



for((i=1;i<=10;i++))
do
  echo 
"This is the $[ 10-$i ] loop"
done 
| sort
echo 
"complete"

输出:
This is the 0 loop
This is the 1 loop
This is the 2 loop
This is the 3 loop
This is the 4 loop
This is the 5 loop
This is the 6 loop
This is the 7 loop
This is the 8 loop
This is the 9 loop
complete


posted on 2010-06-05 18:07 baby-fly 阅读(317) 评论(0)  编辑 收藏 引用 所属分类: Ubuntu&Linux

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理