From d94297fd4de90a3e0ff9a8ff0c2de33fe9aad043 Mon Sep 17 00:00:00 2001 From: Mitchell Paulus Date: Sat, 7 Dec 2024 07:25:41 -0600 Subject: [PATCH] Add awk 15 --- README.md | 8 ++++++-- examples/awk/15.awk | 1 + examples/awk/15.msh | 6 ++++++ examples/awk/test.sh | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 examples/awk/15.awk create mode 100644 examples/awk/15.msh diff --git a/README.md b/README.md index 9bc0c14..01754a4 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,12 @@ wt # 15. Print every line with the first field replaced by the line number # { $1 = NR; print } -# Need a way to write value into an index. -# .. (dup w 1 w w) each +wt 1 lineNum! +( + @lineNum str 0 setAt + " " join wl + @lineNum 1 + lineNum! +) each # 16. Print every line after erasing the second field # { $2 = ""; print } diff --git a/examples/awk/15.awk b/examples/awk/15.awk new file mode 100644 index 0000000..f51170a --- /dev/null +++ b/examples/awk/15.awk @@ -0,0 +1 @@ +{ $1 = NR; print } diff --git a/examples/awk/15.msh b/examples/awk/15.msh new file mode 100644 index 0000000..72a9179 --- /dev/null +++ b/examples/awk/15.msh @@ -0,0 +1,6 @@ +wt 1 lineNum! +( + @lineNum str 0 setAt + " " join wl + @lineNum 1 + lineNum! +) each diff --git a/examples/awk/test.sh b/examples/awk/test.sh index 550809e..be9a432 100755 --- a/examples/awk/test.sh +++ b/examples/awk/test.sh @@ -41,5 +41,6 @@ data_test 11 emp_test 12 emp_test 13 emp_test 14 +emp_test 15 exit "$FAIL"