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.
svn add . --force
find /some/path -type f ! -perm -111 -ls
for i in *.log; do grep OutOfMemo $i >/dev/null && echo $i oom || echo $i ok; done
echo $(printf %08X 256 | grep -o .. | tac | tr -d '\n')
find /directory1/directory2/ -maxdepth 1 -type f | sort | tail -n 5 | xargs md5sum
netstat -rn | awk '/default/ { print $NF }' | head -1 | xargs -I {} ifconfig {} | awk '/ether/ {print $2}'
for path in *.avi; do echo "${path%.avi}"; done | xargs -I{} -P9 HandBrakeCLI -i {}.avi -o {}.mp4
convert -size 100x100 xc:none transparency.png
wget -O - http://placekitten.com/$[500 + RANDOM % 500] | lp
jmap -dump:format=b,file=/var/tmp/dump.hprof 1234
awk 'NR % 10 == 1 {getline f2 < "file1"; print f2} 1' file2 | cat -n
sed -re ':a;Rfile1' -e 'x;s/^/./;/.{10}/!{x;ba};s/.*//;x' file2
is_parent() { [[ "$2" =~ $1/? ]]; }
for img in /path/to/rawimages/*.RW2; do pfsin ${img} | pfssize -x 1024 -y 768 | pfstmo_fattal02 -v -s 1 | pfsout /path/to/finished/${img%%}.jpg; done
uuencode /var/log/messages messages.txt | mailx -s "/var/log/messages on $HOST" me@example.com
md5sum <<< YOUR_TEXT | cut -f1 -d' '
ffmpeg -loop_input -i cover.jpg -i soundtrack.mp3 -shortest -acodec copy output_video.mp4
find . -type f | perl -ne 'print $1 if /\.([^.\/]+)$/' | sort -u
date +"%Y-%m-%d_%H-%M-%Z" | xargs -I {} bash -c "sudo tcpdump -nq -s 0 -i eth0 -w ./dump-{}.pcap"
export psid=$(pgrep -f libflashplayer.so); cp /proc/$psid/fd/$(lsof -p $psid | grep eleted | awk {' print $4 '} | sed -e "s/[a-z]//g") saved.flv
ls | grep '....-..-..-......' | xargs -I {} bash -c "[[ x{} < x$(date -d '3 days ago' +%Y-%m-%d-%H%M%S) ]] && rm -rfv {}"
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
find . -maxdepth 1 -type f -name '\.*' | sed -e 's,^\./\.,,' | sort | xargs -iname mv .name name
for i in *; do mv "$i" "${i^^}"; done
for name in *; do mv "$name" "${name,,}"; done