Presentation is loading. Please wait.

Presentation is loading. Please wait.

Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current.

Similar presentations


Presentation on theme: "Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current."— Presentation transcript:

1 Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current <= $high) @ sum += $current @ current++ end echo The sum of the numbers from $low to $high is $sum.

2 Searching the File Tree: Find Command General form find filename…expression… find ~ -name \*.awk –print Searches the subtree rooted at home directory visiting each file and printing each file that ends in.awk

3 Some important primary expressions -atime n -name filename -exec cmd (end of command must be punctuated by a space then \;) -newer file -print (see pages 149-151 of text for more details)

4 The different shells Name # of internal Size of Complexity of shellcommandsman pages sh3244,0001.0 csh5277,0001.73 bash50 127,000 2.86 zsh73 133,0003.00 ksh43 141,0003.18 tcsh56 199,800 4.99

5 The if Statement – Bourne Shell if [ condition ] then commands else commands fi

6 Test condition operators – Bourne shell String = string String != string Value –eq value Value –ne value Value –gt value Value –ge value Value –lt value Value –le value

7 Referencing arguments – Bourne shell $0, $1, $2, … (same as csh) $* (list of all the variable) $# (number of variables)

8 Bourne shell script #!/bin/sh # lookup a person's phone number in the phone book if [ $# -ne 1 ] then echo "\nusage:$0 name\n" else grep "$1" phone_book fi

9 The while Statement – Bourne Shell while [ condition ] do commands done

10 Infinite Loop while true while :

11 The for Statement – Bourne Shell for variable in list do commands done

12 #!/bin/sh for index in 1 2 3 4 5 do echo $index done

13 Clean - Bourne Shell http://www.ececs.uc.edu/~berman/620/cleanbourne

14 File Types 1.Ordinary file – contains text, programs, or other data 2.Directory – contains names and addresses of other files 3.Special file – represents an I/O device 4.Link – pointer to another file 5.Socket – used for interprocess communication


Download ppt "Integer variables #!/bin/csh # sum of numbers from $argv[1] to $argv[2] set low = $argv[1] set high = $argv[2] set sum = 0 set current = $low while ( $current."

Similar presentations


Ads by Google