Skip to content

Commit

Permalink
Add awk 15
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchpaulus committed Dec 7, 2024
1 parent 2b9b711 commit d94297f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions examples/awk/15.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ $1 = NR; print }
6 changes: 6 additions & 0 deletions examples/awk/15.msh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wt 1 lineNum!
(
@lineNum str 0 setAt
" " join wl
@lineNum 1 + lineNum!
) each
1 change: 1 addition & 0 deletions examples/awk/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ data_test 11
emp_test 12
emp_test 13
emp_test 14
emp_test 15

exit "$FAIL"

0 comments on commit d94297f

Please sign in to comment.