Welcome to bashoneliners.com, a growing collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We review and improve every contributed one-liner to make sure it is 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.
find . -type f -empty -prune -o -type f -printf "%s\t" -exec file --brief --mime-type '{}' \; | awk 'BEGIN {printf("%12s\t%12s\n", "bytes", "type")} {type = $2; a[type] += $1} END {for (i in a) printf("%12u\t%12s\n", a[i], i) | "sort -nr"}'
find . -type f -not -name '*.mp3'
pip install --upgrade $(pip list --outdated | tail -n +3 | awk '{print $1}')
find . -name node_modules -exec rm -rf {} +
echo "${PATH//:/\\n}"
awk '/^#[0-9]*$/ {split($0, arr, "#"); print "#", strftime("%c", arr[2]); getline; print }' < /path/to/.bash_history
echo "${PATH//:/\\n}" | awk '{print length, $0}' | sort -n | cut -f2- -d' '
seq 1 10
let N=0 N=N+10**{0..5}*${RANDOM:0:1}
factorial() { local N; eval let N=1 N*={1..$1}; echo "$N"; }
printf '%s\n' {1..10}
factorial() ( IFS=\*; let N=$1-1 k="$*" && factorial "$N" "$k" || echo ${2-1} )
sudo -s <<< 'apt update -y && apt upgrade -y'
for i in {1..10}; do echo "$i"; done
docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs sudo du -hl
find . -type d -newermt "2019-01-01" ! -newermt "2019-02-01" -exec ls -ld {} \;
for i in {1..65535}; do (< "/dev/tcp/127.0.0.1/$i") &>/dev/null && { echo; echo "[+] Open Port at: $i"; } || printf "."; done; echo
ffmpeg -i video.any -vn -acodec libvorbis audio.ogg
history | awk '{print $2}' | sort | uniq -c | sort -nr | head
(shopt -s dotglob; ls -1d "$PWD"/*)
tr -dc 'a-zA-Z0-9~!@#$%^&*_()+}{?></";.,[]=-' < /dev/urandom | fold -w 32 | head -n 1
(IFS=';'; mkdir $(locale mon))
history 10