首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

shell脚本:一次读取资料的一行

2012-08-08 
shell脚本:一次读取文件的一行转载shell脚本:一次读取文件的一行,并输出 收藏写法一:#!/bin/bashwhile rea

shell脚本:一次读取文件的一行
转载  shell脚本:一次读取文件的一行,并输出 收藏
写法一:
#!/bin/bash
while read line
do
      echo $line     #这里可根据实际用途变化
done < urfile


写法二:

#!/bin/bash

cat urfile | while read line
do
    echo $line
done

注意:以上代码中urfile 为被读取的文件
1 楼 gamegjx 2010-11-04   #!/bin/bash
while read line
do
      echo $line     #这里可根据实际用途变化
done < urfile

--------------- 2 楼 gamegjx 2010-11-04   #!/bin/bash
while read line
do
      echo $line     #这里可根据实际用途变化
done < urfile

---------------

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

请教一下,我需要用第二种方法才有效果呢
与第一种方法有什么区别吗

热点排行