17维客“一起快乐” >>所属分类 >> shell   

用shell处理上MB的文件 编辑词条 发表评论(0)

代码:

  #!/bin/bash

  while IFS=',' read things_before date_string things_after;do

  #remove double quote

  date_string=$(echo $date_string | sed 's/"//g')

  #parse eache field

  year=${date_string:0:4}

  month=${date_string:4:2}

  day=${date_string:6:2}

  hour=${date_string:8:2}

  minute=${date_string:10:2}

  second=${date_string:12:2}

  millisecond=${date_string:14}

  millisecond=$(printf "%06d" $millisecond)

  echo -n $things_before

  echo -n ',"'

  echo -n "$year-$month-$day $hour:$minute:$second.$millisecond"

  echo -n '",'

  echo $things_after

  done这段代码在处理一百多K的文件还行,但是一上兆级的话,处理起来非常非常慢。各位给看看是否可以优化,哪里不太合理啊?谢谢了

附件列表


→如果您认为本词条还有待完善,请 编辑词条

上一篇ubuntu使用apt-cacher加速本地网络软件安装下一篇linux自动删除无用备份

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
0

收藏到: Favorites  

词条信息

hdwiki
hdwiki
书童
词条创建者 发短消息   

相关词条