Unix Lecture 8 - PowerPoint PPT Presentation

About This Presentation
Title:

Unix Lecture 8

Description:

Hints for shell script writing *HW 7 - quiz. LIN 6932. 3 ... http://www.macosxhints.com/article.php?story=20011117235743849. LIN 6932. 13. counter operator ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 15
Provided by: hanaf
Learn more at: http://plaza.ufl.edu
Category:
Tags: lecture | php | shell | unix

less

Transcript and Presenter's Notes

Title: Unix Lecture 8


1
Unix Lecture 8
  • Hana Filip

2
Hints for shell script writing HW 7 - quiz
3
foreach
  • foreach loop
  • foreach var ( worddlist )
  • command(s)
  • end
  • it loops through a range of values.
  • it makes a variable take on each value in a
    specified set, one at a time, and performs some
    action

4
while and foreach
  • foreach var ( worddlist )
  • command(s)
  • end
  • while ( expr )
  • command(s)
  • end

5
while
  • while loop
  • while ( condition )
  • command(s)
  • end
  • The while statement best illustrates how to set
    up a loop to test repeatedly for a matching
    condition
  • The while loop tests a condition in a manner
    similar to the if statement
  • As long as the condition is true, the command(s)
    repeat(s)

6
while
  • Adding integers from 1 to 10
  • !/bin/csh
  • set i1
  • set sum0
  • while (i lt 10)
  • echo Adding i to the sum.
  • set sumexpr sum i
  • set iexpr i 1
  • end
  • echo The sum is sum.

7
input from the keyboard
  • set ans lt

8
generating numbers
  • jot

9
generating numbers
  • jot 3 1
  • 1
  • 2
  • 3
  • generates a series of numbers (3) beginning at 1.

10
generating numbers
  • jot 5 2
  • 2
  • 3
  • 4
  • 5
  • 6
  • generates a series of numbers (5) beginning at 2.

11
generating numbers
  • jot 10 20
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

12
generating numbers
  • A primer on using 'jot' in UNIX
  • http//www.macosxhints.com/article.php?story20011
    117235743849

13
counter operator
  • the increment operator means add one to a
    variable or make a variable's value one more
    than it was before.

14
counter operator
  • used in connection with awk program
  • vi awklw
  • ! /usr/bin/awk -f
  • BEGIN nl 0 nw 0
  • nl nw NF
  • END print "Lines", nl, "words", nw
  • chmod x awklw
  • awklw machen.txt
  • Lines 2538 words 21853
Write a Comment
User Comments (0)
About PowerShow.com