bashoneliners.com

Welcome to bashoneliners.com, a curated collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We aim to make each published one-liner to be of high quality: useful, easy to read, follows best practices, with clear, detailed, accurate explanation. These one-liners should help you automate tasks, troubleshoot problems, whether it be in system administration, file management, networking or programming.

Calculate the total disk space used by a list of files or directories

du -s file1 dir1 | awk '{sum += $1} END {print sum}'

December 28, 2011bashoneliners

Get the available space on a partition as a single numeric value

df /path/to/dir | sed -ne 2p | awk '{print $4}'

October 2, 2011bashoneliners