Next Previous Contents

11. Tables

11.1 String comparison operators

(1) s1 = s2

(2) s1 != s2

(3) s1 < s2

(4) s1 > s2

(5) -n s1

(6) -z s1

(1) s1 matches s2

(2) s1 does not match s2

(3) __TO-DO__

(4) __TO-DO__

(5) s1 is not null (contains one or more characters)

(6) s1 is null

11.2 String comparison examples

Comparing two strings.

        #!/bin/bash
        S1='string'
        S2='String'
        if [ $S1=$S2 ];
        then
                echo "S1('$S1') is not equal to S2('$S2')"
        fi
        if [ $S1=$S1 ];
        then
                echo "S1('$S1') is equal to S1('$S1')"
        fi
        

11.3 Arithmetic operators

+

-

*

/

% (reminder)

11.4 Arithmetic relational operators

-lt (<)

-gt (>)

-le (<=)

-ge (>=)

-eq (==)

-ne (!=)

C programmer's should simple map the operator to its corresponding parenthesis.

11.5 Useful commands

sed (stream editor - very useful)

gawk

grep (show line matching this or not matching that)

wc (count words, lines)

sort

bc (more than a calculator)

cut (edit columns)

tput (get information from the current terminal)

It it higly recommended to be familiarized with this programs (at least). There are tons of little programs that will let you do real magic in a command line.


Next Previous Contents