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.
lsof / | awk '{ if($7 > 1048576) print $7/1048576 "MB" " " $9 " " $1 }' | sort -n -u | tail
find ~ -name ".git" 2> /dev/null | sed 's/\/.git/\//g' | awk '{print "-------------------------\n\033[1;32mGit Repo:\033[0m " $1; system("git --git-dir="$1".git --work-tree="$1" status")}'
echo {01..10}
clear;while x=0; do clear;date;echo "";echo " [Count] | [IP ADDR]";echo "-------------------";netstat -np|grep :80|grep -v LISTEN|awk '{print $5}'|cut -d: -f1|uniq -c; sleep 5;done
for INPUT in *.avi ; do echo "${INPUT%.avi}" ; done | xargs -i -P9 HandBrakeCLI -i "{}".avi -o "{}".mp4
for i in *; do mv "$i" "${i,,}"; done
ifconfig -a | grep -Po '\b(?!255)(?:\d{1,3}\.){3}(?!255)\d{1,3}\b' | xargs nmap -A -p0-
curl -s http://cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^<li>.*</li>' | sed s,\</\\?li\>,,g | shuf -n 1
watch --interval 5 killall -USR1 dd
find . -type f -mtime +1 -name "*.log" -exec zip -m {}.zip {} \; >/dev/null
netstat -tn 2>/dev/null | awk '/:80\>/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
[ test_statement ] && ( then_statement ) || ( else_statement );
$TERMINAL & disown
grep "phpmyadmin" $path_to_access.log | grep -Po "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" | sort | uniq | xargs -I% sudo iptables -A INPUT -s % -j DROP
echo "Here comes the output of my failing code" | tee >(pbcopy)
find . -type f -name '*.java' -exec sh -c 'iconv -f cp1252 -t utf-8 "$1" > converted && mv converted "$1"' -- {} \;
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
printf '%s\n' {1..10}
sudo -s <<< 'apt update -y && apt upgrade -y'
CWD=$(cd "$(dirname "$0")" && pwd)
git commit -m "$(w3m whatthecommit.com | head -n 1)"
for ((i=1; i<=10; ++i)); do echo $i; done
fac() { (echo 1; seq $1) | paste -s -d\* | bc; }
find . -name *conf* -exec grep -Hni 'matching_text' {} \; > matching_text.conf.list
dig +short myip.opendns.com @resolver1.opendns.com