Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.29 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. x=0
  4.  
  5. testfunc () {
  6.   x=$[x+1]
  7.   echo "testfunc: x=$x"
  8. }
  9.  
  10. testfunc
  11. testfunc
  12. testfunc
  13. echo "main/global: x=$x"
  14.  
  15.  
  16. # Output:
  17. #
  18. # [pts/14][user@phobos]:/tmp$ ./test.sh
  19. # testfunc: x=1
  20. # testfunc: x=2
  21. # testfunc: x=3
  22. # main: x=3
  23. # [pts/14][user@phobos]:/tmp$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement