Press "Enter" to skip to content

Passing Values To Bash

Steph Locke shows how to send input parameters to Bash scripts:

This is a very quick post on how you can make a bash script that allows you to provide it values via the command line. Passing values to a bash script uses a 1-based array convention inside the script, that are referenced by prefixing with $ inside the script.

This means that if I provide .\dummyscript.sh value1 value2, inside the dummyscript.sh I can retrieve these by referencing their positions:

Read on for more information, including how to use named parameters.  Given that Bash is now officially supported in Windows 10 (well, in beta form), it might be worth checking that scripting language out.