Wednesday, October 17, 2007

OPS435W5

We use the test command in anything we do, you can test for values and different conditions and decide if its successful then if its not you can do something else, for instance if you look at you rassignment when your doing verification, and even after wards you see if its this or this, or something else, you need the test command in order to test the conditions you are looking for, looking at the

Test Command

Test command test for vgalues how this value compares to this value,

A=3 B=5
Test $a = $b

Two operators the = compares values in their ASCII values


Symbol versus text,


This is where a lot mistakes are made

$?
2 – failed
0 – not successful
1 – successful

-o equals OR

-a and

[ $a –eq $b –o $a –lt 20 –a $b –le 0 ]

The and is done first before the or
Either this is true or this is true

Another version of the test command

[[ $a –eq ]]

The difference between [[]] and []

[[]] can use wild characters * ? ‘ ‘ can use any one of these, while the single brackets cannot

Flow charting to design a program, a map to get their, tell you what to do to accomplish ur project, it takes a large program and breaks it up into small pieces,


/dev/null the garbage bin of linux

Case will try to match patterns against the constants of the variable, the case statement will test for a string in pattern 1, you will have a pattern 1 it will try to match the pattern with the contents of the variable if its true then it will execute the commands under that pattern then it will go t esac (case spelled backwards, closes case) if it doesn’t matches it will go to the next patterns.


The case is looking for a special char wich its closing parenthesis

Case $var in

2[0-6]) ____________;;

T*)
;;

*)
;;

esac
Case can you file name expansion wild chars *? []

Matching 20 – 26 if it has a match it will match and go through the commands
2nd case T*
3rd case * .


How does the case statement know that it will end after the case stement an dyou have to tell it you must add ;;
\

Cat <<++

<< special meaning a hear document, they are saying we have a document that has data in it and the hear document says to the command here is your data, it allows you to provide data to the command inside the program, it can be provide within the program itself, by using a hear document,

you also have to tell the command where the document starts and where it ends, he has a ++ but it can be any pattern that you which, but what every you use you have to tell this is the end,


cat <<++

Main Menu
1. 232
2. 2.432
3. 453
4. Please enter your selection

++

Read banana

Any command at the top it don’t have to be a cat

x|X the pipe in the case statement is an or, you can check for multiple patterns it doesn’t have to be one pattern

case Zodiac sign, u can use it in the day of the week

No comments: