{"id":17148,"date":"2023-08-22T05:37:25","date_gmt":"2023-08-22T05:37:25","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=17148"},"modified":"2024-04-18T09:05:12","modified_gmt":"2024-04-18T09:05:12","slug":"bash-parameters","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/","title":{"rendered":"Parameters in Bash Scripting"},"content":{"rendered":"<p style=\"text-align: justify;\"><strong>Bash scripting <\/strong>is a versatile way to integrate your algorithm with the <strong>Linux <\/strong>operating system. Central to its flexibility are parameters, which allow scripts to accept various inputs, adapt to different scenarios, and <strong>enhance reusability<\/strong>. This article explores the <strong>different aspects <\/strong>of <strong>parameters in Bash scripting<\/strong>, including <strong>positional<\/strong>, <strong>named<\/strong>, even <strong>alias parameters<\/strong>, and so on. So let\u2019s start.<\/p>\n<div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Practice_files_bash-parameters.zip\" class=\"su-button su-button-style-default\" style=\"color:#000000;background-color:#E8F9FF;border-color:#bac8cc;border-radius:56px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#000000;padding:8px 26px;font-size:20px;line-height:30px;border-color:#effbff;border-radius:56px;text-shadow:0px 0px 0px #000000\"><i class=\"sui sui-download\" style=\"font-size:20px;color:#1AA1D6\"><\/i> Practice Files for Parameters in Bash<\/span><\/a><\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#What_is_Bash_Parameter\" >What is Bash Parameter?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#Types_of_Parameters_in_Bash_Scripting\" >Types of Parameters in Bash Scripting<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#1_Bash_Positional_Parameters\" >1. Bash Positional Parameters<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#2_Bash_Optional_Parameters\" >2. Bash Optional Parameters<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#3_Bash_Special_Parameters\" >3. Bash Special Parameters<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#2_Practical_Cases_of_Using_Bash_Parameters\" >2 Practical Cases of Using Bash Parameters<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#1_Using_Bash_Parameters_in_a_Function\" >1. Using Bash Parameters in a Function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#2_Creating_Bash_Alias_with_Parameters\" >2. Creating Bash Alias with Parameters<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#People_Also_Ask\" >People Also Ask<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#How_to_assign_bash_parameters\" >How to assign bash parameters?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#How_to_pass_parameters_to_bash_command\" >How to pass parameters to bash command?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#What_is_0_and_in_shell_scripting\" >What is $0, $? and $# in shell scripting?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#What_is_variable_in_bash\" >What is $$ variable in bash?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#What_is_in_shell_script\" >What is $* in shell script?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"What_is_Bash_Parameter\"><\/span>What is Bash Parameter?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">A <strong>Bash parameter <\/strong>is a value or <strong>piece of information <\/strong>that is passed to a Bash script or function when it is executed. <strong>Parameters<\/strong> enable scripts to <strong>receive inputs<\/strong>, making them more versatile, adaptable, and user-friendly.<\/p>\n<p style=\"text-align: justify;\">Think of <strong>Bash parameters <\/strong>as the secret ingredients you toss into a recipe to give it that <strong>extra specialty<\/strong>. They&#8217;re the values you pass to your scripts when you run them, opening up possibilities. Moreover, you can <strong>customize <\/strong>your <strong>scripts<\/strong>, make them user-friendly, and even handle unexpected twists and turns.<\/p>\n<p style=\"text-align: justify;\">Let&#8217;s say you want to create a script that will greet someone whenever you pass any name to the script. Copy the following code in your<strong> nano editor<\/strong> and execute the file afterwards.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\nname=$1\u00a0 # The first parameter passed to the script\necho &quot;Hello, $name!&quot;<\/code><\/pre>\n<div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#aeb0b3;border-radius:0px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#E1E3E6;color:#000000;border-top-left-radius:0px;border-top-right-radius:0px\"> EXPLANATION<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:0px;border-bottom-right-radius:0px\">\n<p style=\"text-align: justify;\">The first line of our code is a <strong>shebang<\/strong>, and it tells the system to execute the script using the Bash interpreter located at <strong>\/bin\/bash<\/strong>. By using the<strong> name=$1<\/strong>, you&#8217;re assigning the value of the <strong>first positional parameter <\/strong>(provided when the script is run) to the variable name. The variable <strong>$1 <\/strong>holds the <strong>value of <\/strong>the <strong>first parameter <\/strong>passed to the script. Then, <strong>echo &#8220;Hello, $name!&#8221;<\/strong> line uses the <a href=\"https:\/\/linuxsimply.com\/echo-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>echo command<\/strong><\/a> to print out a message. The string then takes the value of the <strong>$name <\/strong>variable and it displays the value. <\/div><\/div><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-17188 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/1.-Using-Bash-Parameter-in-a-script.png\" alt=\"Using Bash Parameter in a script\" width=\"825\" height=\"218\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/1.-Using-Bash-Parameter-in-a-script.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/1.-Using-Bash-Parameter-in-a-script-300x79.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/1.-Using-Bash-Parameter-in-a-script-764x202.png 764w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>As you can see from the image above, whenever I execute the <strong>bash_parameter.sh<\/strong> script with <strong><a href=\"https:\/\/linuxsimply.com\/bash-command-in-linux\/\" target=\"_blank\" rel=\"noopener\">bash command<\/a>, <\/strong>I pass a name along with it. Thus the command line returns <strong>each name <\/strong>I pass followed by the <strong>Hello string<\/strong>. So as you can understand, a particular variable makes this simple code even more flexible to accomplish our task.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Types_of_Parameters_in_Bash_Scripting\"><\/span>Types of Parameters in Bash Scripting<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In <strong>Bash<\/strong>, <strong>parameters<\/strong> refer to the <strong>values or arguments<\/strong> provided to a script or command when it is executed. There are several ways to access these parameters within a script and you can divide<strong> all the parameters <\/strong>into several categories. Down below, I am going to discuss four different types of bash parameters.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Bash_Positional_Parameters\"><\/span>1. Bash Positional Parameters<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>Positional parameters <\/strong>in Bash are a set of variables that capture and retain values passed as arguments when a script or command is invoked. The foremost among these parameters is <strong>$0<\/strong>, which signifies the <strong>name of the script <\/strong>or <strong>command <\/strong>itself. It is essential for self-reference. Accompanying this is a sequence of <strong>$1<\/strong>,<strong> $2<\/strong>, <strong>$3<\/strong>, and so on, representing the arguments provided in the order they appear. For instance, let\u2019s have a look at the following code.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/script.sh arg1 arg2<\/code><\/pre>\n<p style=\"text-align: justify;\">when executing the <strong>\u00a0.\/script.sh arg1 arg2<\/strong>,<strong> $1<\/strong> corresponds to <strong>arg1<\/strong>, and <strong>$2<\/strong> corresponds to <strong>arg2<\/strong>. The script will do certain types of work using those positional values. Additionally, <strong>$#<\/strong> holds the count of arguments passed, offering a numeric perspective on the provided inputs.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Bash_Optional_Parameters\"><\/span>2. Bash Optional Parameters<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In <strong>Bash scripting<\/strong>, <strong>optional parameters<\/strong> can also be implemented using <strong>flags or options<\/strong>. This approach allows users to <strong>provide specific options<\/strong> to the script, and the script responds accordingly. This is also known as <strong>bash parameter parsing<\/strong>. The <strong>getopts command <\/strong>is often used to handle such flags. It&#8217;s a built-in Bash command that simplifies the process of parsing command line options.<\/p>\n<p style=\"text-align: justify;\">Optional parameters are often indicated through <strong>short <\/strong>or <strong>long options<\/strong>. Short options consist of a single character with a preceding <strong>dash (-)<\/strong>, while long options are comprised of words with<strong> two preceding dashes (&#8211;)<\/strong>. The syntax for denoting an <strong>optional parameter <\/strong>in Bash takes the form:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">script_option.sh [-s|--longoption] [argument]<\/code><\/pre>\n<p style=\"text-align: justify;\">In this context, <strong>script_option.sh<\/strong> represents the <strong>script&#8217;s name<\/strong>,<strong> -s <\/strong>serves as a <strong>short option<\/strong>, <strong>&#8211;longoption<\/strong> functions as a <strong>long option<\/strong>, and <strong>argument <\/strong>stands as an <strong>optional argument <\/strong>that can be provided alongside the option. To use <strong>optional parameters <\/strong>in a Bash script, you can use the <strong>getopts<\/strong> <strong>command<\/strong>.<\/p>\n<p>The basic syntax for using <strong>getopts <\/strong>is:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">while getopts &lt;options&gt; &lt;variable&gt;\n\ndo\ncase $&lt;variable&gt; in\n&lt;option1&gt;) &lt;command1&gt; ;;\n&lt;option2&gt;) &lt;command2&gt; ;;\n...\n&lt;optionN&gt;) &lt;commandN&gt; ;;\nesac\n\ndone<\/code><\/pre>\n<p style=\"text-align: justify;\">In this context, <strong>&lt;options&gt;<\/strong> represents a sequence of <strong>permissible options<\/strong>, <strong>&lt;variable&gt;<\/strong> denotes the <strong>variable <\/strong>designated for <strong>holding <\/strong>the current <strong>option<\/strong>, <strong>&lt;option1&gt;<\/strong> through <strong>&lt;optionN&gt;<\/strong> provides the potential options that the script is capable of receiving, and <strong>&lt;command1&gt;<\/strong> through <strong>&lt;commandN&gt;<\/strong> signify the actions that the script should carry out upon receiving the respective option.<\/p>\n<p style=\"text-align: justify;\">By following the abovementioned syntax, you can also create <strong>named parameters <\/strong>to specify options and their corresponding values in a <strong>more intuitive and human-readable<\/strong> manner.<\/p>\n<p><span style=\"color: #800080; font-size: 14pt;\"><strong>Named Parameters in Bash Scripts<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\">Before going to delve into the topic, let\u2019s first understand why you need to use the named parameter instead of using the positional parameter in the first place. As I have already discussed that <strong>positional arguments <\/strong>like<strong> $1<\/strong>, <strong>$2 <\/strong>pass the command-line arguments. However, the effectiveness of <strong>positional arguments <\/strong>is inefficient<strong>\u00a0<\/strong>as it can become <strong>unclear <\/strong>which argument corresponds to which <strong>data type<\/strong>. In contrast, <strong>named arguments <\/strong>offer a more meaningful option, allowing a <strong>precise understanding <\/strong>of the data each argument represents. The basic syntax of the named parameters is as follows:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">scriptname.sh --ParameterName ParameterValue<\/code><\/pre>\n<p style=\"text-align: justify;\">Named parameters typically involve using <strong>flags <\/strong>(<strong>short<\/strong> or <strong>long options <\/strong>i.e ParameterName in the above syntax) to denote <strong>specific parameters <\/strong>and then associating <strong>values <\/strong>with <strong>those flags<\/strong>. This makes it easier for users to remember and provide only the necessary <strong>inputs<\/strong>, even if the script has a <strong>complex set of options<\/strong>.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Bash_Special_Parameters\"><\/span>3. Bash Special Parameters<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Special parameters in Bash are variables that hold specific information, like the <strong>script&#8217;s name,<\/strong> the <strong>number of<\/strong> <strong>arguments <\/strong>passed, <strong>exit status of the last command<\/strong>, and <strong>process IDs<\/strong>. Here is a list of special parameters in Bash:<\/p>\n<div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\">\n<table style=\"width: 100%;height: 610px\">\n<tbody>\n<tr>\n<th style=\"width: 49.6815%\" width=\"301\"><strong>Parameter\u2019s Syntax<\/strong><\/th>\n<th style=\"width: 49.6815%\" width=\"301\"><strong>Description<\/strong><\/th>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$0<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>name of the script <\/strong>or command.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$1, $2, &#8230;<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The positional parameters representing <strong>arguments <\/strong>are provided to the script or command.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$#<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>count <\/strong>of <strong>positional parameters<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$@<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\"><strong>All positional parameters <\/strong>as separate quoted strings.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$?<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>exit status <\/strong>of the last executed command.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$$<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>process ID <\/strong>(<strong>PID<\/strong>) of the current shell.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$!<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>PID <\/strong>of the last background command.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$-<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>current shell <\/strong>options.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$*<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">All positional parameters as a <strong>single string<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">$IFS<\/td>\n<td style=\"width: 49.6815%;text-align: center;vertical-align: middle\" width=\"301\">The <strong>internal field separator<\/strong>, is used for word splitting.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400\"><\/div><\/span><\/p>\n<p>These <strong>special parameters<\/strong> collectively offer insight into the script&#8217;s environment and execution outcomes, thereby facilitating the development of more responsive and adaptable <strong>Bash scripts<\/strong>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"2_Practical_Cases_of_Using_Bash_Parameters\"><\/span>2 Practical Cases of Using Bash Parameters<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">Bash parameters are valuable when you want to add <strong>flexibility <\/strong>and <strong>customization <\/strong>to your scripts. Here are <strong>2 practical cases <\/strong>that I am going to discuss below. Don\u2019t forget to run the provided code in your distribution to understand the concept fully.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Using_Bash_Parameters_in_a_Function\"><\/span>1. Using Bash Parameters in a Function<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><strong>Bash parameters in functions<\/strong> are indispensable when creating <strong>versatile <\/strong>and <strong>interactive <\/strong>scripts. By using parameters, you can dynamically <strong>customize the behavior <\/strong>of your functions based on input values. Let&#8217;s have a practical example that demonstrates how the <strong>function <\/strong>works with Bash parameters.<\/p>\n<p style=\"text-align: justify;\">Suppose you need a function to perform <strong>arithmetic addition operations<\/strong>. You want to pass two numbers as parameters to the function. You can use the following code to accomplish the task:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n# Define a function to calculate the sum of two numbers\ncalculate_sum() {\nlocal num1=$1\nlocal num2=$2\nlocal sum=$((num1 + num2))\necho &quot;The sum of $num1 and $num2 is: $sum&quot;\n}\n\ncalculate_sum $1 $2<\/code><\/pre>\n<p>Here, <strong>$1 and $2<\/strong> bother are bash parameters. Now if you want to run the bash scrip by the following command, you will get an output as given below.<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">.\/bash_function.sh 5 6<\/code><\/pre>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter wp-image-17184 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/2.-Using-Bash-Parameters-in-a-Function.png\" alt=\"Using Bash Parameters in a Function\" width=\"647\" height=\"106\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/2.-Using-Bash-Parameters-in-a-Function.png 647w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/2.-Using-Bash-Parameters-in-a-Function-300x49.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/2.-Using-Bash-Parameters-in-a-Function-763x125.png 763w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/>Upon applying two command line arguments <strong>5<\/strong> and<strong> 6<\/strong>, the <strong>bash_function <\/strong>returns their arithmetic summation by displaying \u201c<strong>The sum of 5 and 6 is: 11<\/strong>\u201d.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Creating_Bash_Alias_with_Parameters\"><\/span>2. Creating Bash Alias with Parameters<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In <strong>Bash<\/strong>, <strong>aliases <\/strong>don&#8217;t support parameters, yet you can work around this by crafting functions that can process <strong>command<\/strong>&#8211;<strong>line<\/strong> arguments. These functions can subsequently be employed as <strong>aliases <\/strong>within your <strong>Linux environment<\/strong>. To illustrate, Let\u2019s have a look at the following command:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">lsdir(){ ls -l $1 | grep &quot;^d&quot;; }<\/code><\/pre>\n<p style=\"text-align: justify;\">The given <strong>alias configuration <\/strong>establishes an <strong>alias <\/strong>labeled <strong>lsdir<\/strong>, which accepts an argument represented by (<strong>$1<\/strong>) denoting the directory that we want to list. When engaging this <strong>alias<\/strong>, you can provide the desired directory as an argument during its invocation. For instance:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">lsdir \/home\/miran<\/code><\/pre>\n<p style=\"text-align: justify;\"><img decoding=\"async\" class=\"aligncenter wp-image-17185 size-full\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/3.-Creating-Bash-Alias-with-Parameters.png\" alt=\"Creating Bash Alias with Parameters\" width=\"825\" height=\"384\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/3.-Creating-Bash-Alias-with-Parameters.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/3.-Creating-Bash-Alias-with-Parameters-300x140.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/3.-Creating-Bash-Alias-with-Parameters-767x357.png 767w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>As the image shows, a detailed <strong>listing of<\/strong> the <strong>folders <\/strong>located in the<strong> \/home\/miran<\/strong> directory and refine the displayed output to exclusively reveal the directory entries.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In conclusion, the <strong>bash parameter <\/strong>is an effective way to communicate and pass the required argument to the bash script. In this article, I have provided an overall understanding of what is bash parameters. I have also discussed the different practical cases to <strong>use and manipulate the bash parameter<\/strong> in your script. However, if you have any questions or queries relevant to this article, don\u2019t forget to comment below. Thank you!<\/p>\n<h2><span class=\"ez-toc-section\" id=\"People_Also_Ask\"><\/span>People Also Ask<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"How_to_assign_bash_parameters\"><\/span>How to assign bash parameters?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In Bash, parameters are assigned using special variables. The most common ones are &#8220;$1&#8221; for the first parameter, &#8220;$2&#8221; for the second, and so on. To assign a value to a variable, you use the &#8220;=&#8221; operator without spaces. For example:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n# Assigning values to variables using parameters\nfirst_param=$1\nsecond_param=$2\n\n# Printing the assigned values\necho &quot;First parameter: $first_param&quot;\necho &quot;Second parameter: $second_param&quot;\n<\/code><\/pre>\n<p>In this script, the values of the first and second parameters passed to the script are assigned to variables <code class=\"\" data-line=\"\">first_param<\/code> and <code class=\"\" data-line=\"\">second_param<\/code>, respectively. The echo statements then print out these assigned values.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_to_pass_parameters_to_bash_command\"><\/span>How to pass parameters to bash command?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To pass parameters to a <strong>Bash command<\/strong>, simply provide the parameters after the command in the command line. For example<strong> command parameter1 parameter2 parameter3<\/strong>. Replace the <strong>command <\/strong>with the <strong>actual command<\/strong> you&#8217;re running, and replace <strong>parameter1<\/strong>, <strong>parameter2<\/strong>, and <strong>parameter3 <\/strong>with the <strong>specific parameters <\/strong>you want to pass to the command.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_0_and_in_shell_scripting\"><\/span>What is $0, $? and $# in shell scripting?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In shell scripting,<strong> $0 <\/strong>represents the <strong>script&#8217;s name <\/strong>or the current shell command, <strong>$?<\/strong> stores the <strong>exit status <\/strong>of the last executed command, and <strong>$#<\/strong> indicates the <strong>count of arguments <\/strong>passed to a script or function.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_variable_in_bash\"><\/span>What is $$ variable in bash?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In Bash scripting, the <strong>$$<\/strong> variable represents the <strong>process ID<\/strong> (<strong>PID<\/strong>) of the currently running script or shell. It provides a <strong>unique identifier<\/strong> for the specific instance of the script or shell session.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_is_in_shell_script\"><\/span>What is $* in shell script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In shell scripting, <strong>$* <\/strong>represents all the <strong>command<\/strong>&#8211;<strong>line<\/strong> <strong>arguments <\/strong>passed to a script as a <strong>single string<\/strong>, with each argument <strong>separated by spaces<\/strong>.<br \/>\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"How to assign bash parameters?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In Bash, parameters are assigned using special variables. The most common ones are \\\"$1\\\" for the first parameter, \\\"$2\\\" for the second, and so on. To assign a value to a variable, you use the \\\"=\\\" operator without spaces.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How to pass parameters to bash command?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"To pass parameters to a Bash command, simply provide the parameters after the command in the command line. For example command parameter1 parameter2 parameter3. Replace the command with the actual command you're running, and replace parameter1, parameter2, and parameter3 with the specific parameters you want to pass to the command.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is $0, $? and $# in shell scripting?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In shell scripting, $0 represents the script's name or the current shell command, $? stores the exit status of the last executed command, and $# indicates the count of arguments passed to a script or function.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is $$ variable in bash?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In Bash scripting, the $$ variable represents the process ID (PID) of the currently running script or shell. It provides a unique identifier for the specific instance of the script or shell session.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is $* in shell script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In shell scripting, $* represents all the command-line arguments passed to a script as a single string, with each argument separated by spaces.\"\n    }\n  }]\n}\n<\/script><\/p>\n<p><strong><span style=\"font-size: 18pt; color: #003366;\">Related Articles<\/span><\/strong><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/all-bash-parameters\/\" target=\"_blank\" rel=\"noopener\">How to Pass All Parameters in Bash Scripts? [6 Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/positional-parameters\/\" target=\"_blank\" rel=\"noopener\">How to Use Positional Parameters in Bash Script? [2 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/parsing\/\" target=\"_blank\" rel=\"noopener\">Parsing Parameters in Bash Scripts [5 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/named-parameters\/\" target=\"_blank\" rel=\"noopener\">4 Methods to Pass Named Parameters in a Bash Script<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/dollar-0\/\" target=\"_blank\" rel=\"noopener\">What is $0 in Bash Script? [4 Practical Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/double-vs-single-dollar\/\" target=\"_blank\" rel=\"noopener\">Difference Between $$ Vs $ in Bash Scripting [With Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/alias-parameters\/\" target=\"_blank\" rel=\"noopener\">How to Use Alias with Parameters in Bash Scripting? [6 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/function-parameters\/\" target=\"_blank\" rel=\"noopener\">How to Use Bash Function with Parameters? [6 Examples]<\/a><\/strong><\/li>\n<\/ul>\n<hr \/>\n<p><strong>&lt;&lt; Go Back to <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Tutorial&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:1065857,&quot;3&quot;:{&quot;1&quot;:0},&quot;10&quot;:1,&quot;11&quot;:4,&quot;12&quot;:0,&quot;17&quot;:1,&quot;23&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/span><\/strong><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-center kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;center&quot;,&quot;id&quot;:&quot;17148&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;10&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\\\/5 - (10 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Parameters in Bash Scripting&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 142.5px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 5px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            5\/5 - (10 votes)    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bash scripting is a versatile way to integrate your algorithm with the Linux operating system. Central to its flexibility are &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Parameters in Bash Scripting\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#more-17148\" aria-label=\"Read more about Parameters in Bash Scripting\">Read more<\/a><\/p>\n","protected":false},"author":314906,"featured_media":17186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[123],"class_list":["post-17148","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-bash-scripting-tutorial","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Parameters in Bash Scripting - LinuxSimply<\/title>\n<meta name=\"description\" content=\"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Parameters in Bash Scripting - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/msmshah.miran\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-22T05:37:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-18T09:05:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mohammad Shah Miran\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohammad Shah Miran\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/\"},\"author\":{\"name\":\"Mohammad Shah Miran\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/3d367dace727c53f2b8683eeb23fae77\"},\"headline\":\"Parameters in Bash Scripting\",\"datePublished\":\"2023-08-22T05:37:25+00:00\",\"dateModified\":\"2024-04-18T09:05:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/\"},\"wordCount\":1814,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/bash-parameters.png\",\"keywords\":[\"bash scripting tutorial\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/\",\"name\":\"Parameters in Bash Scripting - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/bash-parameters.png\",\"datePublished\":\"2023-08-22T05:37:25+00:00\",\"dateModified\":\"2024-04-18T09:05:12+00:00\",\"description\":\"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/bash-parameters.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/bash-parameters.png\",\"width\":400,\"height\":400,\"caption\":\"Bash Parameters in Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/parameters\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bash Scripting Tutorial\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Parameters in Bash Scripting\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"name\":\"LinuxSimply\",\"description\":\"All About Linux\",\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/linuxsimply.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\",\"name\":\"LinuxSimply\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/LinuxSimply-New-Logo-Without-Icon.png\",\"width\":355,\"height\":48,\"caption\":\"LinuxSimply\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/3d367dace727c53f2b8683eeb23fae77\",\"name\":\"Mohammad Shah Miran\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Mohammad-Shah-Miran-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Mohammad-Shah-Miran-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Mohammad-Shah-Miran-II-96x96.png\",\"caption\":\"Mohammad Shah Miran\"},\"description\":\"Hey, I'm Mohammad Shah Miran, previously worked as a VBA and Excel Content Developer at SOFTEKO, and for now working as a Linux Content Developer Executive in LinuxSimply Project. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). As a part of my job, i communicate with Linux operating system, without letting the GUI to intervene and try to pass it to our audience.\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/msmshah.miran\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/shah-miran-2a94a7144\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/miran\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Parameters in Bash Scripting - LinuxSimply","description":"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/","og_locale":"en_US","og_type":"article","og_title":"Parameters in Bash Scripting - LinuxSimply","og_description":"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/msmshah.miran\/","article_published_time":"2023-08-22T05:37:25+00:00","article_modified_time":"2024-04-18T09:05:12+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png","type":"image\/png"}],"author":"Mohammad Shah Miran","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mohammad Shah Miran","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/"},"author":{"name":"Mohammad Shah Miran","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/3d367dace727c53f2b8683eeb23fae77"},"headline":"Parameters in Bash Scripting","datePublished":"2023-08-22T05:37:25+00:00","dateModified":"2024-04-18T09:05:12+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/"},"wordCount":1814,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png","keywords":["bash scripting tutorial"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/","name":"Parameters in Bash Scripting - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png","datePublished":"2023-08-22T05:37:25+00:00","dateModified":"2024-04-18T09:05:12+00:00","description":"Bash parameters enable data transfer to scripts via command line, with positions or names, enhancing script versatility and interaction.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/bash-parameters.png","width":400,"height":400,"caption":"Bash Parameters in Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/parameters\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxsimply.com\/"},{"@type":"ListItem","position":2,"name":"Bash Scripting Tutorial","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/"},{"@type":"ListItem","position":3,"name":"Parameters in Bash Scripting"}]},{"@type":"WebSite","@id":"https:\/\/linuxsimply.com\/#website","url":"https:\/\/linuxsimply.com\/","name":"LinuxSimply","description":"All About Linux","publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxsimply.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxsimply.com\/#organization","name":"LinuxSimply","url":"https:\/\/linuxsimply.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/LinuxSimply-New-Logo-Without-Icon.png","width":355,"height":48,"caption":"LinuxSimply"},"image":{"@id":"https:\/\/linuxsimply.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/3d367dace727c53f2b8683eeb23fae77","name":"Mohammad Shah Miran","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Mohammad-Shah-Miran-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Mohammad-Shah-Miran-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Mohammad-Shah-Miran-II-96x96.png","caption":"Mohammad Shah Miran"},"description":"Hey, I'm Mohammad Shah Miran, previously worked as a VBA and Excel Content Developer at SOFTEKO, and for now working as a Linux Content Developer Executive in LinuxSimply Project. I completed my graduation from Bangladesh University of Engineering and Technology (BUET). As a part of my job, i communicate with Linux operating system, without letting the GUI to intervene and try to pass it to our audience.","sameAs":["https:\/\/www.facebook.com\/msmshah.miran\/","https:\/\/www.linkedin.com\/in\/shah-miran-2a94a7144\/"],"url":"https:\/\/linuxsimply.com\/author\/miran\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/17148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/users\/314906"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=17148"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/17148\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/17186"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=17148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=17148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=17148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}