sed n 2,4p example - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

sed n 2,4p example

Description:

the file has one line per address with fields separated by a colon ... Use filter awk to convert transformed canonical file into desired address labels ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 9
Provided by: dieters
Category:
Tags: address | example | labels | sed

less

Transcript and Presenter's Notes

Title: sed n 2,4p example


1
sed -n 2,4p example
2
sed n /aAggararwal/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

4
Hints for hw2
  • Transform record file into canonical form
  • JOE DOE40 NORTH BENDCINCINNATIOHIO45212
  • MARY SMITH345 NEW ROADOLD CITYNEW 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//_at_/' myaddr \
  • tr '\012_at_' '\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
  • argvi represents the ith argument, i.e.,
  • argvi is the same as i, i 1, , 9.
Write a Comment
User Comments (0)
About PowerShow.com