Skip to content

Instantly share code, notes, and snippets.

@greyaperez
Created December 10, 2013 15:42
Show Gist options
  • Save greyaperez/7892680 to your computer and use it in GitHub Desktop.
Save greyaperez/7892680 to your computer and use it in GitHub Desktop.
Some of the most useful bash/shell functions and aliases.
alias editbash='vim ~/.bashrc'
alias updatebash='source ~/.bashrc'
alias ls='ls -alC --color=auto'
function search (){
egrep -roiI $1 . | sort | uniq
}
function whereis (){
find . -name "$1*";
}
# Find What is Using a Particular Port
# USAGE: $ whoisport 80
function whoisport (){
port=$1
pidInfo=$(fuser $port/tcp 2> /dev/null)
pid=$(echo $pidInfo | cut -d':' -f2)
ls -l /proc/$pid/exe
}
function mysql-import (){
if [ $# -lt 2 ];
then
echo 'mysql-import {DB-NAME} {SQL-FILE}';
else
mysql $1 < $2;
fi
}
# Tail Files in Directory
# USAGE: $ log {arg1:file filter(opt)} {arg2:string filter(opt)}
function log (){
if [ $# -lt 1 ];
then
tail -f *
fi
if [ $# -gt 1 ];
then
tail -f $1 | grep --line-buffered "$2"
else
tail -f $1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment