There is a shell, there is a way…
This is the study notes about bash shell-scripting. In part I, I would like to cover basic commands for starters.
Prelude
I have a memory shortage condition and this is just to warm up my scripting skills. Don’t expect to explain things. If you have strong imagination,that might works.
Some Env Setup
alias
create shortcut to save your fingers
$ set completion-ignore-case On
fuck the case-sensitive
’#!/bin/bash’
this ‘#i’ is called shebang. Declares that you are start banging with bash.
Variables
like php,everything is with $ sign.
Read input
sometimes,you want variables from outside world.
Some more advanced reading
this is for smarty pant.
Positional parameters
if you know how to count one two and three,you can do it!
Small bash program
This is a bash script that did something which makes sense.
#! /bin/sh
calculate the length of the hypotenuse of a Pythagorean triangle
using hypotenuse^2 = adjacent^2 + opposite^2
###Wildcards
####Globbing It’s a term comes from global and it will searchs all trees from the whole forest.
Quoting
Not a big deal but minor issues are the thing that destory the most.