From charlesreid1

Revision as of 02:36, 9 October 2010 by Admin (talk | contribs) (→‎Bash Guide)

Bash Guide

Using Bash

Setting the default shell: http://www.unix.com/shell-programming-scripting/32664-how-change-default-shell-linux.html


Startup Process

source /etc/profile

source ~/.profile

(source ~/.bash_profile?)

source /etc/bashrc

source ~/.bashrc


Dot Files

Tricks

Looping

Looping in bash is really simple, and convenient - you can use other unix commands (most obviously "ls") to create lists, and then loop over each element of those lists. For example, if I want to print out the name of every file in my home directory (granted, not very useful, but this is just an example), I can do this:

for i in `/bin/ls -1 $HOME`; do
    echo $i
done

Math

References

Floating point math in the shell:

http://www.novell.com/coolsolutions/tools/17043.html

Fast bash math:

http://www.bytemycode.com/snippets/snippet/350/

Bash script iterate through array of values

http://www.tech-recipes.com/rx/636/bash-shell-script-iterate-through-array-values/