1 / 4

CS311 – Lecture 07 Outline

CS311 – Lecture 07 Outline. Worksheet 2 tr – translate and delete gawk – programmable text processing Note: These lecture notes are not intended replace your notes. This is what I expect your notes to already look like, but with more explanation as needed. 1. tr - translate and delete.

finley
Download Presentation

CS311 – Lecture 07 Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS311 – Lecture 07 Outline Worksheet 2 tr – translate and delete gawk – programmable text processing Note: These lecture notes are not intended replace your notes. This is what I expect your notes to already look like, but with more explanation as needed. CS311 – Operating Systems 1 1

  2. tr - translate and delete • gets its input through input redirection or pipes. This util doesn't allow a filename. • translate SET1 to SET2 • delete SET1 CS311 – Operating Systems 1 2

  3. gawk - programmable text processing • scans one or more files and perform an action on all of the lines that match a particular condition. gawk [options] [-f fileName] program {variable=value} {fileName} • Lines of the program are of the form:condition {action} • With no condition, the action is performed on every line. • With no action, the lines matching the condition are printed. Conditions are things like: • NR>2 Each line is a "record". NR is the number of this record (line number) • NF>5 Each word is a "field". NF is the number of this fields in this record CS311 – Operating Systems 1 3

  4. gawk - programmable text processing (cont.) • Lines of the program are of the form:condition {action} • Actions look very C like and are things like: • printf $2; Print the second field. • awk '{if($2=="fleece") {printf $3; printf "\n";}}' bbb • Actions are always surrounded in { }'s • awk is an older version of gawk. CS311 – Operating Systems 1 4

More Related