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.
w | tail -n +3 | cut -d ' ' -f1 | sort -u
pip install --upgrade $(pip list --outdated | tail -n +3 | awk '{print $1}')
lsof -i :8080 | awk '{print $2}' | tail -n 1 | xargs kill
lsof / | awk '$7 > 1048576 { print $7 / 1048576 "MB", $9, $1 }' | sort -nu | tail
find /directory1/directory2/ -maxdepth 1 -type f | sort | tail -n 5 | xargs md5sum
tail -f /path/to/file.log | sed '/^Finished: SUCCESS$/ q'
{ echo some text; echo; tail -n1 /var/log/apache2/error.log; } >> /path/to/file
echo -e "From: me\n\n$(tail -n1 /var/log/apache2/error.log)" >> file
find /path/to/dir -type f | perl -ne 'chomp(@files = <>); my $p = 9; foreach my $f (sort { (stat($a))[$p] <=> (stat($b))[$p] } @files) { print scalar localtime((stat($f))[$p]), "\t", $f, "\n" }' | tail