Shell, Bash script default parameters


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.