~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to test/ofs1.awk

  • Committer: Arnold D. Robbins
  • Date: 2012-11-25 19:54:48 UTC
  • mfrom: (319.1.122)
  • Revision ID: git-v1:9a9ff61bbd952c1263b55f82a269da5b09289a6b
Merge branch 'master' into array-iface

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Translate this shell script into gawk:
 
2
#
 
3
#! /bin/sh -
 
4
 
5
# awktest()
 
6
# {
 
7
#   echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}'
 
8
#   echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}'
 
9
#   echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}'
 
10
#   echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}'
 
11
# }
 
12
 
13
# AWK=./gawk
 
14
# awktest > foo.gawk
 
15
 
 
16
BEGIN { FS = ":" }
 
17
 
 
18
# Have to reset OFS at end since not running separate invocations
 
19
 
 
20
FNR == 1 { $2 = "x"; OFS = FS; print ; OFS = " "}
 
21
FNR == 2 { $2 = "x"; print; OFS = FS; print ; OFS = " "}
 
22
FNR == 3 { $2 = "x"; print $1; OFS = FS; print ; OFS = " "}
 
23
FNR == 4 { $2 = "x"; print; $2 = $2; OFS = FS; print }