summaryrefslogtreecommitdiff
path: root/test/ofs1.awk
diff options
context:
space:
mode:
Diffstat (limited to 'test/ofs1.awk')
-rwxr-xr-xtest/ofs1.awk23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ofs1.awk b/test/ofs1.awk
new file mode 100755
index 00000000..83b3c2a5
--- /dev/null
+++ b/test/ofs1.awk
@@ -0,0 +1,23 @@
+# Translate this shell script into gawk:
+#
+#! /bin/sh -
+#
+# awktest()
+# {
+# echo a:b:c | $AWK -F":" '{$2="x"; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print $1; OFS=FS; print}'
+# echo a:b:c | $AWK -F":" '{$2="x"; print; $2=$2; OFS=FS; print}'
+# }
+#
+# AWK=./gawk
+# awktest > foo.gawk
+
+BEGIN { FS = ":" }
+
+# Have to reset OFS at end since not running separate invocations
+
+FNR == 1 { $2 = "x"; OFS = FS; print ; OFS = " "}
+FNR == 2 { $2 = "x"; print; OFS = FS; print ; OFS = " "}
+FNR == 3 { $2 = "x"; print $1; OFS = FS; print ; OFS = " "}
+FNR == 4 { $2 = "x"; print; $2 = $2; OFS = FS; print }