powershell convert text 20MB to bytes
$str = '3GB'
$int64 = [int64]$str.Replace('GB','') * 1GBfunction Convert-Size {
[cmdletbinding()]
param(
[validateset("Bytes","KB","MB","GB","TB")]
[string]$From,
[validateset("Bytes","KB","MB","GB","TB")]
[string]$To,
[Parameter(Mandatory=$true)]
[double]$Value,
[int]$Precision = 4
)
switch($From) {
"Bytes" {$value = $Value }
"KB" {$value = $Value * 1024 }
"MB" {$value = $Value * 1024 * 1024}
"GB" {$value = $Value * 1024 * 1024 * 1024}
"TB" {$value = $Value * 1024 * 1024 * 1024 * 1024}
}
switch ($To) {
"Bytes" {return $value}
"KB" {$Value = $Value/1KB}
"MB" {$Value = $Value/1MB}
"GB" {$Value = $Value/1GB}
"TB" {$Value = $Value/1TB}
}
return [Math]::Round($value,$Precision,[MidPointRounding]::AwayFromZero)
}
Also in Shell:
- github graphql query to get your repos
- npm install package globally
- undo last commit
- how to stop a port in macos
- commit the add complete folder to github
- how to get stashed on git
- @react-navigation/drawer install
- create directory linux
- how do i clone a specific branch in git
- react quill
- FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
- undo git pull origin master into feature branch
- remove directory in cmd
- fatal: 'heroku' does not appear to be a git repository
- add alias fish shell
- git bash Could not open a connection to your authentication agent. when adding ssh
- how see my user name mac terminal
- only show first lines linux
- sed replace in file
- python-swiftclient 3.5.0 uninstall ubuntu
- sublime text linux
- linux vim set tab to 4 spaces
- python execute shell command and get output
- The repository 'https://download.docker.com/linux/ubuntu focal Release' does not have a Release file