码迷,mamicode.com
首页 > 系统相关 > 详细

Powershell split file

时间:2014-11-27 12:33:33      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   sp   on   log   cti   ad   ef   

#网上所得非原创

function split($inFile, $outPrefix, [Int32] $bufSize){

$stream = [System.IO.File]::OpenRead($inFile)
$chunkNum = 1
$barr = New-Object byte[] $bufSize

while( $bytesRead = $stream.Read($barr,0,$bufsize)){
$outFile = "$outPrefix$chunkNum"
$ostream = [System.IO.File]::OpenWrite($outFile)
$ostream.Write($barr,0,$bytesRead);
$ostream.close();
echo "wrote $outFile"
$chunkNum += 1
}
}

split ‘F:\log\u_ex141125.log‘ ‘F:\log\iis‘ 1000

Powershell split file

标签:io   ar   os   sp   on   log   cti   ad   ef   

原文地址:http://www.cnblogs.com/superunusa/p/4125906.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!