To get free space on / in a machine-readable single number (bytes):
/
df --output=avail -B1 /
This prints a header line, so to get only the value:
df --output=avail -B1 / | tail -n 1
Options:
--output=avail
-B1
K
M
Common variations:
# Kilobytes (1024-byte blocks, classic "df -k" style) df -k --output=avail / | tail -n 1 # Human-readable only for eyeballing (not machine-safe) df -h / # Portable alternative (POSIX, works even without GNU df) stat -f -c '%s * %f' / | bc # %s = fundamental block size, %f = free blocks
You can also get used/total alongside if you need them:
df -B1 --output=size,used,avail /
The df --output=avail -B1 / | tail -n 1 form is the standard idiom: stable, unversioned output, safe to parse in scripts.
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more