Gregor Gorjanc's shell functions and scripts
A set of functions and scripts that make my life easier when working in shell/terminal. These are not necesarilly bomb proof, but do the job. Feel free to improve them!
The functions/scripts are:
- cpumemlog - monitor CPU and RAM usage
- cwdiff - color word diff
- browse - open file browser application from working folder
- dim,nrow,ncol - number of rows and columns in an rectangular file
- find* - find files and folders quickly
- func - print out a function
- hi - search in the .history file
- open - my attempt at generic file opener from the terminal
- psu,psux - find user's processes and where they are running
- remove_header - remove first row in a file
- repeat - repeat something
- rmd,cld,... - various remove functions
- rows,cols - print a subset of rows and cols
- see,see_col,head_col,tail_col - print few rows of a file
- server - generate a set of aliases for a set of servers
- qstat*,qdelall - manipulate SGE cluster jobs
- stop,reboot - stop and reboot computer
- sys_info - retrieve system information (RAM, processors, disk, ...)
- x2y - convert files from one type to another
- tarc,tarx,zipc,zipx - (un)compress a given folder
- grepall - grep recursively
- pwdx - print working directory of a process
- qwc - quick wc
- spaces - replace filename spaces with _
Functions are stored in files named func_foo.sh while scripts are stored in files named foo.
- Save the files in your ~/bin folder or clone repo and link the files to ~/bin or elsewhere
- Add
/bin folder to your PATH variable, i.e., export PATH=/bin:$PATH - In order to be able to use functions, add the following code to your ~/.bashrc file for each function you want to use:
if [ -f ~/bin/func_foo.sh ]; then
source ~/bin/func_foo.sh
fi
or for a set of functions:
FUNCS="func_foo1.sh
func_foo2.sh"
for FILE in ${FUNCS}; do
if [ -f "~/bin/${FILE}" ]; then
source ~/bin/${FILE}
fi
done