sed & awk, 2nd Edition by Dale Dougherty;Arnold Robbins

sed & awk, 2nd Edition by Dale Dougherty;Arnold Robbins

Author:Dale Dougherty;Arnold Robbins
Format: mobi
Tags: COMPUTERS / Operating Systems / UNIX
Publisher: O'Reilly Media
Published: 2010-11-19T00:00:00+00:00


Before any input is read, the bitmap array is loaded with O's. This array has 144 elements. The input to this program is a series of coordinates, one per line.

$ cat bitmap.test

1,1

2,2

3,3

4,4

5,5

6,6

7,7

8,8

9,9

10,10

11,11

12,12

1,12

2,11

3,10

4,9

5,8

6,7

7,6

8,5

9,4

10,3

11,2

12,1

For each coordinate, the program will put an "X" in place of an "O" as that element of the array. At the end of the script, the same kind of loop that loaded the array, now outputs it. The following example reads the input from the file bitmap.test.

$ awk -f bitmap.awk bitmap.test

XOOOOOOOOOOX

OXOOOOOOOOXO

OOXOOOOOOXOO

OOOXOOOOXOOO

OOOOXOOXOOOO

OOOOOXXOOOOO

OOOOOXXOOOOO

OOOOXOOXOOOO

OOOXOOOOXOOO

OOXOOOOOOXOO

OXOOOOOOOOXO

XOOOOOOOOOOX



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.