Hadoop HDFS 预览

PowerShell创建临时文本文件并上传至hadoop


临时搭建了一个简约版hadoop单机环境,在测试hdfs时,想创建一批临时文件看看效果。因为bash shell 不熟,只能切换到pwsh环境中,见证PowerShell跨平台的时候到了:

1..100 | foreach {
$lineCount = 500 
$bs=New-Object System.Text.StringBuilder $lineCount*26
1..$lineCount | foreach{
$txt = [guid]::NewGuid()
$bs.Append($txt) | Out-Null
$bs.AppendLine() | Out-Null
$txt
}

$file = [guid]::NewGuid().ToString()
$bs.ToString() | Out-File $file
$bs=$null

Write-Host "正在写入 $file ..." 
hadoop fs -put $file /user/

Remove-Item $file
}
Hadoop HDFS 预览

Hadoop HDFS 预览

本文链接: https://www.pstips.net/gen-text-file-and-put-to-hadoop.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

关于 Mooser Lee

我是一个Powershell的爱好者,创建了PowerShell中文博客,热衷于Powershell技术的搜集和分享。本站部分内容来源于互联网,不足之处敬请谅解,并欢迎您批评指正。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注