(→Bash) |
|||
8번째 줄: | 8번째 줄: | ||
<syntaxhighlight lang='bash' run> | <syntaxhighlight lang='bash' run> | ||
df --block-size=1 --output=used / | sed 1d | df --block-size=1 --output=used / | sed 1d | ||
</syntaxhighlight> | |||
==Go== | |||
[[분류: Go]] | |||
{{참고|Go disk_used_space}} | |||
<syntaxhighlight lang='go' run> | |||
package main | |||
import ( | |||
"fmt" | |||
"golang.org/x/sys/unix" | |||
) | |||
func main() { | |||
var stat unix.Statfs_t | |||
unix.Statfs("/", &stat) | |||
fmt.Println((stat.Blocks - stat.Bavail) * uint64(stat.Bsize)) | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
2023년 2월 26일 (일) 17:42 기준 최신판
1 개요[ | ]
- 함수 disk_used_space()
2 Bash[ | ]

Bash
Copy
df --block-size=1 --output=used / | sed 1d
Loading
3 Go[ | ]

Go
Copy
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
func main() {
var stat unix.Statfs_t
unix.Statfs("/", &stat)
fmt.Println((stat.Blocks - stat.Bavail) * uint64(stat.Bsize))
}
Loading
4 PHP[ | ]

PHP
Copy
<?php
echo disk_total_space("/")-disk_free_space("/");
Loading