Posted By

mecha on 05/27/11


Tagged

Shell Bash default parameters


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

drules


Shell, Bash script default parameters


 / Published in: Bash
 

  1. #!/bin/bash
  2.  
  3. echo "--------------------------------------"
  4. echo "Script name ................... [ $0 ]"
  5. echo "First parameter ............... [ $1 ]"
  6. echo "Second parameter .............. [ $2 ]"
  7. echo "Process ID .................... [ $$ ]"
  8. echo "Parameter count ............... [ $# ]"
  9. echo "All parameters ................ [ $@ ]"
  10. echo "FLAGS ......................... [ $- ]"
  11. echo "--------------------------------------"
  12.  
  13. # EXAMPLE OUTPUT:
  14. # > ./shell-play-2.sh param1 param2
  15. # --------------------------------------
  16. # Script name ................... [ ./shell-play-2.sh ]
  17. # First Parameter ............... [ param1 ]
  18. # Second Parameter .............. [ param2 ]
  19. # Process ID .................... [ 555 ]
  20. # Parameter Count ............... [ 2 ]
  21. # All Parameters ................ [ param1 param2 ]
  22. # FLAGS ......................... [ hB ]
  23. # --------------------------------------

Report this snippet  

You need to login to post a comment.