1 / 8

sed -n 2,4p example

sed -n 2,4p example. sed –n /[aA]gg*[ar][ar]wal/p example. Records in a file in following format. Doe JOE 897-9090 40 North Bend, Cincinnati, Ohio 45212 Smith marry 345 New Road, Old City New York 345689 Doe, joe 40 North Bend Cincinnati Ohio 45122 Spears Britney

Download Presentation

sed -n 2,4p example

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. sed -n 2,4p example

  2. sed –n /[aA]gg*[ar][ar]wal/p example

  3. Records in a file in following format Doe JOE 897-9090 40 North Bend, Cincinnati, Ohio 45212 Smith marry 345 New Road, Old City New York 345689 Doe, joe 40 North Bend Cincinnati Ohio 45122 Spears Britney 531-6767 1 Star street Hollywood CA 78789

  4. Hints for hw2 • Transform record file into canonical form: • JOE DOE:40 NORTH BEND:CINCINNATI:OHIO:45212 • MARY SMITH:345 NEW ROAD:OLD CITY:NEW YORK: 345689: etc. the file has one line per address with fields separated by a colon • Addresses are cleaned-up, converted to upper case, sorted with duplicates removed

  5. Use filters sed, tr and sort to transform record file. Below are some of the steps involved. sed 's/^$/@/' myaddr \ | tr '\012@' ':\012' \ | sed 's/^://;s/:$//' \ | sort –u –t: +0 –3

  6. Use filter awk to convert transformed canonical file into desired address labels

  7. Passing Arguments to Shell Programs • To reference arguments from inside a shell program use $i where i is an integer from 0 to 9. The name of the script is represent by $0. $1, $2, …, $9 represent argument 1, argument 2, …, argument 9.

  8. Number of arguments • The number of arguments is represented by argv • argv[i] represents the ith argument, i.e., argv[i] is the same as $i, i = 1, …, 9.

More Related