Guest User

Untitled

a guest
Nov 14th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. $ cat go.awk
  2. BEGIN {
  3. print "The BEGIN block is executing"
  4. print reverse("The BEGIN block is executing")
  5. }
  6.  
  7. {
  8. print reverse($0)
  9. }
  10.  
  11. function reverse(str) {
  12. trs=""
  13. for(i=length(str); i > 0; i--) {
  14. trs=trs substr(str, i, 1);
  15. }
  16. return trs
  17. }
  18.  
  19. $ cat input
  20. line one
  21. line two
  22. line three
  23.  
  24. $ awk -f go.awk < input
  25. The BEGIN block is executing
  26. gnitucexe si kcolb NIGEB ehT
  27. eno enil
  28. owt enil
  29. eerht enil
Add Comment
Please, Sign In to add comment