Not only useful in programming, regular expressions can make complex tasks easy in many different scenarios. Here is a great site for testing your regex:
http://rubular.com
!!sudo !!^foo^barctrl + R
watch -n 2 -d '/sbin/ifconfig eth0'ip addr |awk '/inet/ {sub(/\/.*/, "", $2); print $2}'or
ifconfig -a |awk 'BEGIN{FS="[ :]+"} /Bcast/{print $4}'This command will return the number of Apache processes running on the remote host.
ssh user@host 'ps -ef | grep apache | grep -v grep | wc -l'This command will grab the first 8 lines from the top output, showing vital system stats.
ssh user@host 'top -b -n 1 | head -n 8'cat /var/log/apache2/access_log | awk '{print $1}' | sort | uniq -c | sort -rn | moreSearch the current directory (represented by the period) and below it for files and directories with names starting with ex:
find . -name "ex*"Find only files:
find . -type f -name "ex*"Find only directories:
find . -type d -name "ex*"Find within a certain directory:
find /home/example -name "ex*"find . -iname "ex*"find . -type f -iname "*.php"find . -type f \( -iname "*.php" -o -iname "*.htm*" -o -iname "*.css" \)Examples of using find switches to filter out items from the search results.
Filter out items owned by apache, named, webalizer or cgi-bin:
find . -not -user apache -and -not \( -iname "webalizer" -prune -or -iname "cgi-bin" -prune \)The find command is made extra useful by redirecting its output to other commands. Below are some handy examples of using find output.
Moving all files in a directory to another location:
find . -type f -name '*.bak' -exec mv '{}' backup_dir/ \;find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;find . -type f -iname "*.php" -print0 |xargs -0 grep -i -n "example"find . -type f -not \( -iname "webalizer" -prune -or -iname "_admin" -prune -or -iname "__sd" \) -print0 |xargs -0 tar --no-recursion Szcf myfiles.tar.gzfind . -type f -mtime 30 -print0 |xargs -0 tar --no-recursion -Szcf archive.tar.gzctrl + Ac
ctrl + Aa
ctrl + An
ctrl + Ap
ctrl + Ad
screen -lsscreen -R -d {session_id}open {filename}open -a {app} {filename}python -m SimpleHTTPServer