昨天做了星辰的题,今天继续来凑热闹。- $ cat practice1_file
- a,20131213,EQ,131313,333333
- a,20131216,EQ,161616,666666
- a,20131217,EQ,171717,777777
- c,20131218,EQ,181818,888888
- c,20131219,EQ,191919,999999
- e,20131220,EQ,202020,222222
- f,20131223,FI,234324,123213
- g,20131224,FI,242424,444444
- g,20131225,FI,252525,555555
复制代码- #!/bin/bash
- #practice1.sh
- awk -F"," '
- BEGIN{
- print "entity\tentity_type\teffectivedate\tresult";
- }
- {
- if(i == $1)
- {
- printf "%s\t%s\t\t%s\t%s+%s-%s/%s\n", $1, $3, $2, $5, $4, j, j;
- }
- i = $1;
- j = $5;
- }
- ' practice1_file
复制代码 |