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"