{"id":14037,"date":"2023-08-02T04:20:10","date_gmt":"2023-08-02T04:20:10","guid":{"rendered":"https:\/\/linuxsimply.com\/?p=14037"},"modified":"2024-02-18T08:30:53","modified_gmt":"2024-02-18T08:30:53","slug":"bash-get-script-name","status":"publish","type":"post","link":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/","title":{"rendered":"How to Get Script Name Using Bash Script? [3 Easy Ways]"},"content":{"rendered":"<p style=\"text-align: justify;\">Suppose you want to get the script name currently running using a <strong>Bash script<\/strong>. To get the bash script name from the script itself, you can use the <strong>basename command<\/strong>, <strong>parameter expansion<\/strong>, <strong>redlink command<\/strong>, and even show the path of the script along with its name. In this article, I am going to demonstrate all methods to bash get the script name in simple ways.<\/p>\n<p style=\"text-align: left;\"><div class=\"su-button-center\"><a href=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/08\/Practice-Files_get-scriptname.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 to Get Bash Script Name<\/span><\/a><\/div>\n<div class=\"su-youtube su-u-responsive-media-yes\"><iframe width=\"600\" height=\"400\" src=\"https:\/\/www.youtube.com\/embed\/LrOL6XEWVxc?\" frameborder=\"0\" allowfullscreen allow=\"autoplay; encrypted-media; picture-in-picture\" title=\"\"><\/iframe><\/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' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#3_Methods_to_Get_Script_Name_Using_Bash_Scripting\" >3 Methods to Get Script Name Using 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-2\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#1_Get_the_Script_Name_Using_%E2%80%9Cbasename%E2%80%9D_Command\" >1. Get the Script Name Using &#8220;basename&#8221; Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#2_Get_Script_Name_Along_With_Directory_Path\" >2. Get Script Name Along With Directory Path<\/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\/basics\/examples\/get-script-name\/#3_Get_the_Script_Name_Using_Parameter_Expansion\" >3. Get the Script Name Using Parameter Expansion<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#Comparison_of_Methods_to_Get_Bash_Script_Name\" >Comparison of Methods to Get Bash Script Name<\/a><\/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\/basics\/examples\/get-script-name\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#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-8\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#How_to_get_file_name_in_shell_script\" >How to get file name in shell script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#How_to_read_bash_script\" >How to read bash script?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#What_is_a_shell_script_file\" >What is a shell script file?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#What_is_bin_bash_for\" >What is bin bash for?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"3_Methods_to_Get_Script_Name_Using_Bash_Scripting\"><\/span>3 Methods to Get Script Name Using Bash Scripting<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In this section, you will learn how to get a script name using <strong>Bash Scripting.<\/strong> I have demonstrated three methods of getting the script name using the <strong>basename command<\/strong>, <strong>parameter expansion<\/strong>, and I have shown the path along with the script names.<\/p>\n<p><span style=\"font-weight: 400;\"><div class=\"su-note\"  style=\"border-color:#e5e3d9;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFFDF3;border-color:#ffffff;color:#333333;\"><\/span>You can read our <a href=\"#comparative-analysis\"><strong>Comparison of Methods<\/strong><\/a> to distinguish between these three methods and pick the best one for your needs.<span style=\"font-weight: 400;\"><\/div><\/div><\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Get_the_Script_Name_Using_%E2%80%9Cbasename%E2%80%9D_Command\"><\/span>1. Get the Script Name Using &#8220;basename&#8221; Command<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In this method, you are going to see how to use the <strong>basename command<\/strong> to get the script name. This command takes a filename and prints it. So, I have used this in my script along with<strong> $0<\/strong> to get the script name.<\/p>\n<p style=\"text-align: justify;\">To get the script name using the <code class=\"\" data-line=\"\">basename<\/code> command, check the below-mentioned script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Retreive script name being executed\nscript_name1=`basename $0`\n\n#Display script name\necho &quot;The script that you\u2019re running is:$script_name1&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, <code class=\"\" data-line=\"\">#!\/bin\/bash<\/code> is called shebang, which specifies the interpreter as Bash, which will be used to execute the script. The <code class=\"\" data-line=\"\">$0<\/code> actually returns the full name of your script, but along with the <strong>basename<\/strong>, it returns the filename without any path names in it. Then the file name is assigned to the <strong>script_name1 variable<\/strong>. Again, the <a href=\"https:\/\/linuxsimply.com\/echo-command-in-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>echo command<\/strong><\/a> and the<strong> $script_name1<\/strong> variable print the script name.<\/div><\/div>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-14040\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.Getting-script-name-using-basename-command.png\" alt=\"Getting script name using basename command\" width=\"825\" height=\"104\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.Getting-script-name-using-basename-command.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.Getting-script-name-using-basename-command-300x38.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/1.Getting-script-name-using-basename-command-762x96.png 762w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>After running the script, I got the script name printed.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Get_Script_Name_Along_With_Directory_Path\"><\/span>2. Get Script Name Along With Directory Path<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">In this method, I have printed the script name along with the path. Along with the basename command, I\u2019ve used the <strong>realpath command<\/strong> to get the absolute path of the script. You can do so by using the following script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n#Retreive the script name\nscript_name=`basename &quot;$(realpath $0)&quot;`\n\n#Display the script name\necho &quot;The script that you\u2019re running is:$script_name&quot;\n\n#Retreive the path\nscript_path=$(dirname $(readlink -f $0))\npath_and_name=&quot;$script_path\/$script_name&quot;\n\n#Display script path and script name\necho &quot;The script you\u2019re running with path: $path_and_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\">As in the first script, this code also starts with <code class=\"\" data-line=\"\">#!\/bin\/bash<\/code>, which specifies the Bash interpreter.<\/p>\n<p style=\"text-align: justify;\">Then a variable script_name assigns the name of the script, using the<strong> basename command <\/strong>along with the <strong>real path command<\/strong>, to get the absolute path of the script. Then the echo command prints the script name.<\/p>\n<p style=\"text-align: justify;\">In the next line, a variable named <strong>script_path<\/strong> is used to assign the script path, where I have used the <code class=\"\" data-line=\"\">dirname<\/code> command along with the <code class=\"\" data-line=\"\">readlink -f<\/code> command to get the absolute path of the script\u2019s directory.<\/p>\n<p style=\"text-align: justify;\">After that, a variable<strong> path_and_name<\/strong> is used to assign the concatenation of previous variables, forming the absolute path and name of the script. Finally, the <code class=\"\" data-line=\"\">echo<\/code> command displays the file path and name of the script.\u00a0 <\/div><\/div>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14041\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Getting-script-name-along-with-path.png\" alt=\"Getting script name along with path\" width=\"825\" height=\"128\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Getting-script-name-along-with-path.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Getting-script-name-along-with-path-300x47.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/2.-Getting-script-name-along-with-path-767x119.png 767w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/p>\n<p style=\"text-align: justify;\">The script has printed the script file name along with the path of the script.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Get_the_Script_Name_Using_Parameter_Expansion\"><\/span>3. Get the Script Name Using Parameter Expansion<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In this method, I have used <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/expansion\/parameter-expansion\/\" target=\"_blank\" rel=\"noopener\"><strong>parameter expansion<\/strong><\/a> to perform pattern matching to get the script name. To do so you can use the below script:<\/p>\n<pre><code class=\"language-bash\" data-line=\"\">#!\/bin\/bash\n\n# Get the script name using parameter expansion\nscript_name=&quot;${0##*\/}&quot;\necho &quot;Script name using parameter expansion: $script_name&quot;<\/code><\/pre>\n<p style=\"text-align: justify;\"><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\">The variable <strong>script_name <\/strong>is used to assign the script name. The script name is found using the parameter expansion, where <code class=\"\" data-line=\"\">${0}<\/code> represents the value of the <strong>$0 <\/strong>variable, which is the script&#8217;s name or path. And <code class=\"\" data-line=\"\">##*\/<\/code> is a pattern that matches and removes the longest occurrence of <strong>*\/<\/strong>. So, overall, <code class=\"\" data-line=\"\">${0##*\/} <\/code>removes the path component from the script\u2019s name, resulting in <strong>only the script name<\/strong>. Finally, the script name is printed using the <strong>echo command<\/strong>, whenever the script is run.\u00a0 <\/div><\/div>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-14042\" src=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Getting-script-name-using-parameter-expansion.png\" alt=\"Getting script name using parameter expansion\" width=\"825\" height=\"135\" srcset=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Getting-script-name-using-parameter-expansion.png 825w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Getting-script-name-using-parameter-expansion-300x49.png 300w, https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/3.-Getting-script-name-using-parameter-expansion-764x125.png 764w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/>See from the image, after running the script, the script name is shown.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Comparison_of_Methods_to_Get_Bash_Script_Name\"><\/span><a id=\"comparative-analysis\"><\/a>Comparison of Methods to Get Bash Script Name<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\">In this section, I will give you a comparative analysis of the three methods mentioned above so you can understand which will be best for you to use:<\/p>\n<div class=\"su-table su-table-responsive su-table-alternate su-table-fixed\">\n<table style=\"height: 113px;width: 100%\" width=\"100%\">\n<thead>\n<tr style=\"height: 16px\">\n<th style=\"height: 16px;width: 16.2424%\" width=\"94\"><strong>Methods<\/strong><\/th>\n<th style=\"height: 16px;width: 41.3333%\" width=\"246\"><strong>Pros<\/strong><\/th>\n<th style=\"height: 16px;width: 41.3333%\" width=\"246\"><strong>Cons<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 57px\">\n<td style=\"height: 57px;width: 16.2424%;text-align: center\" width=\"94\"><strong>Method 1<\/strong><\/td>\n<td style=\"height: 57px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>The syntax is quite easy to use.<\/li>\n<\/ul>\n<\/td>\n<td style=\"height: 57px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>You need to know the command and its syntax.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr style=\"height: 25px\">\n<td style=\"height: 25px;width: 16.2424%;text-align: center\" width=\"94\"><strong>Method 2<\/strong><\/td>\n<td style=\"height: 25px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>You can get the path along with the file name.<\/li>\n<\/ul>\n<\/td>\n<td style=\"height: 25px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>If you don\u2019t need a file path, it contains redundant information.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr style=\"height: 15px\">\n<td style=\"height: 15px;width: 16.2424%;text-align: center\" width=\"94\"><strong>Method 3<\/strong><\/td>\n<td style=\"height: 15px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>Searches for files and gets the exact filename.<\/li>\n<\/ul>\n<\/td>\n<td style=\"height: 15px;width: 41.3333%\" width=\"246\">\n<ul>\n<li>You have to remember the signs and their sequences to use them correctly.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"text-align: justify;\">Any user can use the <strong>first and third methods<\/strong> only to get the file name. The first method is easier, as there is no need to memorize the parameter expansion signs.\u00a0 On the other hand, users who need to know the path of the file can easily go for <strong>method 2<\/strong>,<\/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;\">Finally, you have an overview of <strong>bash scripts<\/strong> to get the script name, and you can use any of these methods according to your convenience. Getting a<strong> script name<\/strong> seems like an easy task, but when you deal with a huge number of scripts, it becomes difficult to handle. Feel free to ask any questions or share your thoughts related to this article.<\/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 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_to_get_file_name_in_shell_script\"><\/span>How to get file name in shell script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">If you want to get the file name in a shell script, use the<strong> basename command<\/strong>. By using this command, you can extract the filename along with the extension from a file path and store it in a predefined variable in a shell script.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"How_to_read_bash_script\"><\/span>How to read bash script?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">There are several techniques to read a bash command, and one of them is using the <strong>cat command<\/strong>. To use it, simply type <code class=\"\" data-line=\"\">cat &lt;filename&gt;<\/code> in your command line.\u00a0 And, you can see the contents of your bash file on your screen.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"What_is_a_shell_script_file\"><\/span>What is a shell script file?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">A<strong> shell script<\/strong> file is a file that contains one or more commands that are executed by the shell in sequence.<\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"What_is_bin_bash_for\"><\/span>What is bin bash for?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The <code class=\"\" data-line=\"\">\/bin\/bash<\/code> is used to instruct the operating system to use bash as the command interpreter. This line is also called the <strong>shebang.<\/strong><\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"How to get file name in shell script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"If you want to get the file name in a shell script, use the basename command. By using this command, you can extract the filename along with the extension from a file path and store it in a predefined variable in a shell script.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"How to read bash script?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"There are several techniques to read a bash command, and one of them is using the cat command. To use it, simply type cat <filename> in your command line.\u00a0 And, you can see the contents of your bash file on your screen.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is a shell script file?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"A shell script file is a file that contains one or more commands that are executed by the shell in sequence.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"What is bin bash for?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The \/bin\/bash is used to instruct the operating system to use bash as the command interpreter. This line is also called the shebang.\"\n    }\n  }]\n}\n<\/script><\/p>\n<p><span style=\"font-size: 18pt; color: #003366;\"><strong>Related Articles<\/strong><\/span><\/p>\n<ul>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-date\/\" target=\"_blank\" rel=\"noopener\">How to Get Date in Bash [2 Methods with Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/print-time\/\" target=\"_blank\" rel=\"noopener\">How to Print Time in Bash [2 Quick Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/list-users\/\" target=\"_blank\" rel=\"noopener\">How to List Users in Bash [2 Easy Ways]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/current-time\/\" target=\"_blank\" rel=\"noopener\">How to Get Current Time in Bash [4 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/date-format\/\" target=\"_blank\" rel=\"noopener\">How to Use Date Format in Bash [5 Examples]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-timestamp\/\" target=\"_blank\" rel=\"noopener\">How to Get Timestamp in Bash [2 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/copy-paste\/\" target=\"_blank\" rel=\"noopener\">How to Copy and Paste in Bash [2 Methods &amp; Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/read-password\/\" target=\"_blank\" rel=\"noopener\">How to Read Password in Bash [3 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/send-email\/\" target=\"_blank\" rel=\"noopener\">How to Send Email in Bash [2 Easy Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/send-email-with-attachment\/\" target=\"_blank\" rel=\"noopener\">Bash Script to Send Email with Attachment [Step-by-Step Guide]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-ip-address\/\" target=\"_blank\" rel=\"noopener\">How to Get IP Address in Bash [3 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/find-and-replace\/\" target=\"_blank\" rel=\"noopener\">How to Find and Replace String in Bash [5 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/call-another-script\/\" target=\"_blank\" rel=\"noopener\">How to Call Another Script in Bash [2 Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/generate-uuid\/\" target=\"_blank\" rel=\"noopener\">How to Generate UUID in Bash [3 Simple Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/write-to-file\/\" target=\"_blank\" rel=\"noopener\">3 Easy Ways to Write to a File in Bash Script<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/output-to-file\/\" target=\"_blank\" rel=\"noopener\">How to Write the Output to a File in Bash Script [5 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/list-in-bash\/\" target=\"_blank\" rel=\"noopener\">How to Create a List in Bash Scripts? [2 Easy Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/clear-history\/\" target=\"_blank\" rel=\"noopener\">How to Clear History in Bash [2 Practical Cases]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/clear-screen\/\" target=\"_blank\" rel=\"noopener\">How to Clear Screen Using Bash Script? [2 Effective Methods]<\/a><\/strong><\/li>\n<li><strong><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/check-ubuntu-version\/\" target=\"_blank\" rel=\"noopener\">How to Check Ubuntu Version Using Bash Scripts? [2 Methods]<\/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;28 Essential Bash Script Examples&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\/basics\/examples\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/\" target=\"_blank\" rel=\"noopener\">Bash Script Examples<\/a> <\/span>| <span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Bash Scripting Basics&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:16768,&quot;10&quot;:1,&quot;11&quot;:4,&quot;17&quot;:1}\" data-sheets-hyperlink=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\"><a class=\"in-cell-link\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Basics<\/a><\/span>\u00a0| <a href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/\" target=\"_blank\" rel=\"noopener\">Bash Scripting Tutorial<\/a><\/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;14037&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;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&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;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;How to Get Script Name Using Bash Script? [3 Easy Ways]&quot;,&quot;width&quot;:&quot;0&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: 0px;\">\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            <span class=\"kksr-muted\">Rate this post<\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Suppose you want to get the script name currently running using a Bash script. To get the bash script name &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"How to Get Script Name Using Bash Script? [3 Easy Ways]\" class=\"read-more button\" href=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#more-14037\" aria-label=\"Read more about How to Get Script Name Using Bash Script? [3 Easy Ways]\">Read more<\/a><\/p>\n","protected":false},"author":314902,"featured_media":14039,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[114],"class_list":["post-14037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash-scripting","tag-bash-script-examples","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>How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply<\/title>\n<meta name=\"description\" content=\"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.\" \/>\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\/basics\/examples\/get-script-name\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply\" \/>\n<meta property=\"og:description\" content=\"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/\" \/>\n<meta property=\"og:site_name\" content=\"LinuxSimply\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/samayra.simi?mibextid=LQQJ4d\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-02T04:20:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-18T08:30:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.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=\"Lamisa Musharrat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Lamisa Musharrat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 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\\\/basics\\\/examples\\\/get-script-name\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/\"},\"author\":{\"name\":\"Lamisa Musharrat\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#\\\/schema\\\/person\\\/6c8ce99861d6ee19a49c62dfad934181\"},\"headline\":\"How to Get Script Name Using Bash Script? [3 Easy Ways]\",\"datePublished\":\"2023-08-02T04:20:10+00:00\",\"dateModified\":\"2024-02-18T08:30:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/\"},\"wordCount\":1270,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/4.-Bash-Get-Script-Name.png\",\"keywords\":[\"bash script examples\"],\"articleSection\":[\"Bash Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/\",\"name\":\"How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/4.-Bash-Get-Script-Name.png\",\"datePublished\":\"2023-08-02T04:20:10+00:00\",\"dateModified\":\"2024-02-18T08:30:53+00:00\",\"description\":\"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#primaryimage\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/4.-Bash-Get-Script-Name.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/4.-Bash-Get-Script-Name.png\",\"width\":400,\"height\":400,\"caption\":\"Bash get script name\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/get-script-name\\\/#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\":\"Bash Scripting Basics\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Bash Script Examples\",\"item\":\"https:\\\/\\\/linuxsimply.com\\\/bash-scripting-tutorial\\\/basics\\\/examples\\\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to Get Script Name Using Bash Script? [3 Easy Ways]\"}]},{\"@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\\\/6c8ce99861d6ee19a49c62dfad934181\",\"name\":\"Lamisa Musharrat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Lamisa-Musharrat-II-96x96.png\",\"url\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Lamisa-Musharrat-II-96x96.png\",\"contentUrl\":\"https:\\\/\\\/linuxsimply.com\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/Lamisa-Musharrat-II-96x96.png\",\"caption\":\"Lamisa Musharrat\"},\"description\":\"Hello there. My name is Lamisa Musharat, and I'm an Linux Content Developer Executive at SOFTEKO. I earned a bachelor's degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology (BUET).I learned Linux out of my curiosity and now I find it useful as automation is easier using Linux. I take great pleasure in assisting others with Linux-related issues. I really want you to enjoy and benefit from my efforts.Read Full Bio\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/samayra.simi?mibextid=LQQJ4d\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/lamisa-musharrat-ba1631250\\\/\"],\"url\":\"https:\\\/\\\/linuxsimply.com\\\/author\\\/siimi\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply","description":"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.","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\/basics\/examples\/get-script-name\/","og_locale":"en_US","og_type":"article","og_title":"How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply","og_description":"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.","og_url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/","og_site_name":"LinuxSimply","article_author":"https:\/\/www.facebook.com\/samayra.simi?mibextid=LQQJ4d","article_published_time":"2023-08-02T04:20:10+00:00","article_modified_time":"2024-02-18T08:30:53+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.png","type":"image\/png"}],"author":"Lamisa Musharrat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Lamisa Musharrat","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#article","isPartOf":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/"},"author":{"name":"Lamisa Musharrat","@id":"https:\/\/linuxsimply.com\/#\/schema\/person\/6c8ce99861d6ee19a49c62dfad934181"},"headline":"How to Get Script Name Using Bash Script? [3 Easy Ways]","datePublished":"2023-08-02T04:20:10+00:00","dateModified":"2024-02-18T08:30:53+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/"},"wordCount":1270,"commentCount":0,"publisher":{"@id":"https:\/\/linuxsimply.com\/#organization"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.png","keywords":["bash script examples"],"articleSection":["Bash Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/","url":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/","name":"How to Get Script Name Using Bash Script? [3 Easy Ways] - LinuxSimply","isPartOf":{"@id":"https:\/\/linuxsimply.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#primaryimage"},"image":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#primaryimage"},"thumbnailUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.png","datePublished":"2023-08-02T04:20:10+00:00","dateModified":"2024-02-18T08:30:53+00:00","description":"In this article, I have showed how to get script name using Bash script. You will see three methods to bash get script name including path.","breadcrumb":{"@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#primaryimage","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/07\/4.-Bash-Get-Script-Name.png","width":400,"height":400,"caption":"Bash get script name"},{"@type":"BreadcrumbList","@id":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/get-script-name\/#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":"Bash Scripting Basics","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/"},{"@type":"ListItem","position":4,"name":"Bash Script Examples","item":"https:\/\/linuxsimply.com\/bash-scripting-tutorial\/basics\/examples\/"},{"@type":"ListItem","position":5,"name":"How to Get Script Name Using Bash Script? [3 Easy Ways]"}]},{"@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\/6c8ce99861d6ee19a49c62dfad934181","name":"Lamisa Musharrat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Lamisa-Musharrat-II-96x96.png","url":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Lamisa-Musharrat-II-96x96.png","contentUrl":"https:\/\/linuxsimply.com\/wp-content\/uploads\/2023\/09\/Lamisa-Musharrat-II-96x96.png","caption":"Lamisa Musharrat"},"description":"Hello there. My name is Lamisa Musharat, and I'm an Linux Content Developer Executive at SOFTEKO. I earned a bachelor's degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology (BUET).I learned Linux out of my curiosity and now I find it useful as automation is easier using Linux. I take great pleasure in assisting others with Linux-related issues. I really want you to enjoy and benefit from my efforts.Read Full Bio","sameAs":["https:\/\/www.facebook.com\/samayra.simi?mibextid=LQQJ4d","https:\/\/www.linkedin.com\/in\/lamisa-musharrat-ba1631250\/"],"url":"https:\/\/linuxsimply.com\/author\/siimi\/"}]}},"_links":{"self":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14037","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\/314902"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/comments?post=14037"}],"version-history":[{"count":0,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/posts\/14037\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media\/14039"}],"wp:attachment":[{"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/media?parent=14037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/categories?post=14037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxsimply.com\/wp-json\/wp\/v2\/tags?post=14037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}