From charlesreid1

No edit summary
No edit summary
Line 38: Line 38:


== Math ==
== Math ==
=Bash Commands=
==Editing Commands==
The following are keyboard shortcuts for easy navigation/editing of commands that are on the Bash command line.
===Movement===
* '''C-a''' - Move to beginning of line
* '''C-e''' - Move to end of line
* '''M-f''' - Move forward 1 word
* '''M-b''' - Move backward 1 word
* '''C-f''' - Move forward 1 character
* '''C-b''' - Move backward 1 character
===Cutting and Pasting===
* '''C-k''' - kill (cut) from cursor to end of line
* '''C-w''' - kill (cut) from cursor to previous whitespace
* '''C-y''' - yank (paste) previously killed text at cursor
===Uncategorized===
* '''C-L''' - clear screen, reprint current line at top
* '''C-u''' - undo last edit
* '''C-d''' - delete character under cursor


= References =
= References =

Revision as of 08:51, 31 March 2011

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

Bash Scripting

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

Bash Commands

Editing Commands

The following are keyboard shortcuts for easy navigation/editing of commands that are on the Bash command line.

Movement

  • C-a - Move to beginning of line
  • C-e - Move to end of line


  • M-f - Move forward 1 word
  • M-b - Move backward 1 word


  • C-f - Move forward 1 character
  • C-b - Move backward 1 character

Cutting and Pasting

  • C-k - kill (cut) from cursor to end of line
  • C-w - kill (cut) from cursor to previous whitespace
  • C-y - yank (paste) previously killed text at cursor

Uncategorized

  • C-L - clear screen, reprint current line at top
  • C-u - undo last edit
  • C-d - delete character under cursor

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/