use IFS in bash

 

function dfd()
{
    #http://www.cnblogs.com/hunterfu/archive/2010/02/23/1672129.html
    IFS=$'\n'
    for i in $(lsd);do
        du -sh "$i";
    done 
}

 

  #!/bin/bash
  IFS_old=$IFS      #将原IFS值保存,以便用完后恢复
  IFS=$’\n’         #更改IFS值为$’\n’
  for line in `cat file.txt`
  do
  echo $line
  done


posted @ 2013-07-24 20:52  爱生活,爱编程  阅读(328)  评论(0编辑  收藏  举报