临时搭建了一个简约版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
}
本文链接: https://www.pstips.net/gen-text-file-and-put-to-hadoop.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

