返回首页 我的新博客

shell脚本:一次读取文件的一行,并输出

写法一:
#!/bin/bash
while read line
do
      echo $line     #这里可根据实际用途变化
done < urfile
────────────────────────────────────────────────────────────────────────────────────

写法二:

#!/bin/bash

cat urfile | while read line
do
    echo $line
done

注意:以上代码中urfile 为被读取的文件

posted @ 2009-11-24 16:11  buffer的blogs  阅读(1300)  评论(0编辑  收藏  举报