Welcome to, 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.


Watch a mashup of many video files

L=5; while true; do; readarray -t paths < <(find . -type f -print | shuf -n 1); for i in "${!paths[@]}"; do; path=${paths[i]}; if ffprobe -i "$path" -show_entries format=duration -v quiet -of csv="p=0" > /dev/null; then; N=$(ffprobe -i "$path" -show_entries format=duration -v quiet -of csv="p=0"); D=${N%.*}; P=$((D / 100 * 25)); R=$((1 + RANDOM % D - P * 2)); S=$((P + RANDOM % R)); W=$((R / 4)); LEN=$((1 + RANDOM % L)); mpv "$path" --start="$S" --length="$LEN" --fs &> /dev/null; W=$(bc <<< "$LEN - 0.5"); sleep "$W"; unset 'paths[i]'; fi; done; done

July 6, 2023krypniok


Extract audio only from video files using ffmpeg

ffmpeg -i video.any -vn -acodec libvorbis audio.ogg

April 21, 2019bashoneliners


Concatenate two or more movie files into one using mencoder

mencoder cd1.avi cd2.avi -o movie.avi -ovc copy -oac copy

December 24, 2011bashoneliners


Rotate a movie file with mencoder

mencoder video.avi -o rotated-right.avi -oac copy -ovc lavc -vf rotate=1

December 2, 2011bashoneliners