{"id":2639,"date":"2023-03-25T00:38:50","date_gmt":"2023-03-24T19:08:50","guid":{"rendered":"https:\/\/smarttech101.com\/?p=2639"},"modified":"2024-02-22T21:19:15","modified_gmt":"2024-02-22T15:49:15","slug":"how-to-create-shell-scripts-in-linux-unix","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/","title":{"rendered":"How to Create Shell Scripts in Linux\/Unix"},"content":{"rendered":"\n<p class=\"\">In simple terms, shell script in Linux\/Unix is a group of commands you execute in your shell. Just copy and paste your commands into a file and your shell script is prepared. Shell scripts can alleviate your need for many software. Using shell scripts you can <strong>automate most of your tasks.<\/strong><\/p>\n\n\n\n<p class=\"\">In this article, I will talk about Posix shells &#8211;<strong> mainly bash shell<\/strong>. Most of these commands will also work in other POSIX-compliant shells such as <a href=\"https:\/\/smarttech101.com\/zsh-highlighting-autosuggestion-themes-binding-alias-fzf\/\" target=\"_blank\" rel=\"noreferrer noopener\">Zsh<\/a> and Dash. First, I will tell you about basic commands like how to set and get variables and their values. Then, I will talk about how to create and run shell scripts. <\/p>\n\n\n\n<p class=\"\"><strong>\ud83d\udcdd Note: <\/strong>If you have knowledge of any programming language, it will be easier to understand bash shell. But I will describe each step, so don&#8217;t worry.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"#variables_and_basic_commands_in_bash_shell_in_linux\">Variables and basic commands in bash shell in Linux<\/a>\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"#how_to_define_variables_in_bash_shell\">How to define variables in bash shell<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#how_to_get_the_value_of_any_variable_in_bash_shell_in_linux\">How to get the value of any variable in the bash shell in Linux<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"\"><a href=\"#how_to_prepare_shell_scripts_in_linuxunix\">How to prepare shell scripts in Linux\/Unix<\/a>\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"#step_1_create_a_file_with_first_line_specifying_the_shell\">Step 1: Create a file with the first line specifying the shell<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#step_2_put_all_shell_commands_in_the_file\">Step 2: Put all shell commands in the file<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"#step_3_set_appropriate_execution_bit_on_the_file\">Step 3: Set the appropriate execution bit on the file<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"\"><a href=\"#how_to_run_shell_scripts_in_linuxunix\">How to run shell scripts in Linux\/Unix<\/a>\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"#path_variable_in_linux\">PATH variable in Linux<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li class=\"\"><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"variables_and_basic_commands_in_bash_shell_in_linux\">Variables and basic commands in bash shell in Linux<\/h2>\n\n\n\n<p class=\"\">Open your terminal, launch the bash shell, and learn these basic commands first.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how_to_define_variables_in_bash_shell\">How to define variables in bash shell<\/h3>\n\n\n\n<p class=\"\">To define a variable and its value, you just need to follow the simple method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ variable=value<\/code><\/pre>\n\n\n\n<p class=\"\">Where, the value can be an integer, floating point number (i.e. a number with decimal), or strings (i.e. texts)<\/p>\n\n\n\n<p class=\"\">Examples:<\/p>\n\n\n\n<p class=\"\">Number:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ x=3<\/code><\/pre>\n\n\n\n<p class=\"\">String:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ y=\"item_number_one\"<\/code><\/pre>\n\n\n\n<p class=\"\">Please note that there is no space around the equal <code>=<\/code> sign.<\/p>\n\n\n\n<p class=\"\">It is good to<strong> always use quotes around your values<\/strong>, otherwise, you might get errors caused by &#8220;splitting&#8221;, or &#8220;substitution&#8221;. They are not errors per se. These splitting and substitution have a special application. I will talk about them in later articles.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ variable='United States'<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how_to_get_the_value_of_any_variable_in_bash_shell_in_linux\">How to get the value of any variable in the bash shell in Linux<\/h3>\n\n\n\n<p class=\"\">To get the values of these variables, you need to prepend <code>$<\/code> to these variable names. For example, <code>x<\/code> becomes <code>$x<\/code>, <code>y<\/code> becomes <code>$y<\/code> and so on. Now, I will be using echo to give you simple examples. <a href=\"https:\/\/smarttech101.com\/echo-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">To know more about echo, look at my article on it<\/a>.<\/p>\n\n\n\n<p class=\"\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ echo \"this is value of x: $x\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>this is value of x: 3<\/code><\/pre>\n\n\n\n<p class=\"\">Notice how the <code>$x<\/code> has been substituted by its value.<\/p>\n\n\n\n<p class=\"\">If you don&#8217;t give any value to any variable, you will get <code>null<\/code> result. For example, for an undefined variable <code>z<\/code>, I get the following result:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ echo \"this is value of z: $z\"\n\nthis is value of z:<\/code><\/pre>\n\n\n\n<p class=\"\">Variable name comprises:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"\">Word constituent character (<code>\\w<\/code>): numbers, upper and lowercase alphabets, and underscore ( <code>_<\/code> )<\/li>\n\n\n\n<li class=\"\">It should not start with a number.<\/li>\n<\/ol>\n\n\n\n<p class=\"\">For example, <code>variable_name<\/code>, <code>variable2<\/code> is allowed but <code>2variable<\/code> is not allowed.<\/p>\n\n\n\n<p class=\"\">To learn more about <a href=\"https:\/\/smarttech101.com\/bash-commands-in-linux-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">bash shell in Linux, look at this article<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_prepare_shell_scripts_in_linuxunix\">How to prepare shell scripts in Linux\/Unix<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step_1_create_a_file_with_first_line_specifying_the_shell\">Step 1: Create a file with the first line specifying the shell<\/h3>\n\n\n\n<p class=\"\">First, open a file called <code>~\/example.sh<\/code> using your favorite text editor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ gedit ~\/example.sh<\/code><\/pre>\n\n\n\n<p class=\"\">The first line should tell which shell to be used. For example, to use bash shell, use the following in the first line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<\/code><\/pre>\n\n\n\n<p class=\"\"><strong>zsh shell<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/zsh<\/code><\/pre>\n\n\n\n<p class=\"\"><strong>dash shell<\/strong>,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/dash<\/code><\/pre>\n\n\n\n<p class=\"\">Please note that <code>\/bin\/bash<\/code> is the path to bash binary. You can use any binary like that of python (<code>\/bin\/python<\/code>), gawk (<code>\/bin\/gawk<\/code>), etc. If your shell binaries are located in other paths, use them instead. (For example, <code>#!\/usr\/bin\/bash<\/code>)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step_2_put_all_shell_commands_in_the_file\">Step 2: Put all shell commands in the file<\/h3>\n\n\n\n<p class=\"\">Now, whatever commands you want to run, put them into the file. For examples given above, I will be writing the following commands in the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\nx=3\necho \"this is value of x: $x\"\necho \"this is value of z: $z\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step_3_set_appropriate_execution_bit_on_the_file\">Step 3: Set the appropriate execution bit on the file<\/h3>\n\n\n\n<p class=\"\">You might already know that files have permissions like read (<code>r<\/code>) and write (<code>w<\/code>). If a file does not have write permission, it means you cannot write anything into it.<\/p>\n\n\n\n<p class=\"\">Similarly, there is another permission called &#8216;execute&#8217; permission (<code>x<\/code>). In order to &#8216;run&#8217; any file, you need to set this permission. Linux, by default, removes this permission on all newly created files. This is a security feature in Linux. So, you need to set the execution bit (i.e. &#8216;execute&#8217; permission). Use the following command to set the execution bit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ chmod +x your_file_name<\/code><\/pre>\n\n\n\n<p class=\"\">So for the file name <code>example.sh<\/code>, the command will be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ chmod +x example.sh<\/code><\/pre>\n\n\n\n<p class=\"\">Now, your <strong>shell script is prepared<\/strong>. You can run it now.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how_to_run_shell_scripts_in_linuxunix\">How to run shell scripts in Linux\/Unix<\/h2>\n\n\n\n<p class=\"\">There are many methods to run shell scripts. Two methods are:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li class=\"\">Run the script using any shell<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ bash file_name<\/code><\/pre>\n\n\n\n<p class=\"\">Or,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ sh file_name<\/code><\/pre>\n\n\n\n<p class=\"\">Or,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ zsh file_name<\/code><\/pre>\n\n\n\n<p class=\"\">2. To run any shell script go to the folder in which it is located on your terminal type <code>.\/file_name<\/code> and then hit the Enter button.<\/p>\n\n\n\n<p class=\"\">For example, to run the above shell script, <code>~\/example.sh<\/code>. First, open your terminal, go to the home directory using the <code>cd<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ cd ~ <\/code><\/pre>\n\n\n\n<p class=\"\">Now, run the command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ .\/example.sh<\/code><\/pre>\n\n\n\n<p class=\"\">Going to the script&#8217;s directory each time we want to run the script is a cumbersome process. To remove this much work, you can include the script&#8217;s directory in the variable <code>PATH<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"path_variable_in_linux\">PATH variable in Linux<\/h3>\n\n\n\n<p class=\"\">PATH variable sets a group of directories separated by a colon (<code>:<\/code>). If you run your script from your terminal (or anywhere), the Linux system will look into these directories and try to find the file <code>example.sh<\/code>. If it cannot find the file, it will throw an error.<\/p>\n\n\n\n<p class=\"\">The default value of the <code>PATH<\/code> variable in your PC can be found using <code>echo<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ echo \"$PATH\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/bin:\/usr\/lib\/jvm\/default\/bin:\/usr\/bin\/site_perl:\/usr\/bin\/vendor_perl:\/usr\/bin\/core_perl:\/home\/ajay\/.local\/share\/npm\/bin<\/code><\/pre>\n\n\n\n<p class=\"\">So, if you want your computer to find your script, you need to put it in one of these directories. My recommendation will be to create a special directory for your personal scripts. I use <code>~\/.my_scripts<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ mkdir ~\/.my_scripts<\/code><\/pre>\n\n\n\n<p class=\"\">Now, move all of your personal script files into this directory. Then add this directory into the PATH using <code>export<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>export PATH=${PATH}:~\/.my_scripts\/<\/code><\/pre>\n\n\n\n<p class=\"\">However, the above command is just a temporary addition. When you log out from your system, this path is excluded automatically. To add permanently, open the file <code>~\/.profile<\/code> and\/or <code>~\/.zshrc<\/code> using your favorite text editor and add the above <code>export<\/code> line in the end.<\/p>\n\n\n\n<p class=\"\">Now, you can run your script easily. Just type the file name and hit enter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ file_name<\/code><\/pre>\n\n\n\n<p class=\"\">For example, if we want to execute the above script <code>example.sh<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;ajay@legion ~]$ example.sh<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>this is value of x: 3\nthis is value of z: <\/code><\/pre>\n\n\n\n<p class=\"\">Now, you can bind this script to a shortcut key. Then you will never need a terminal to execute it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"\">That&#8217;s all. This was a basic introduction to shell scripting. Now, you need to <a href=\"https:\/\/smarttech101.com\/category\/command-line-tools\/\" target=\"_blank\" rel=\"noreferrer noopener\">learn about Linux command line tools<\/a>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/bc-command-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">bc &#8211; calculator<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/regular-expression-regex-and-regexp-in-linux-ft-grep\/\" target=\"_blank\" rel=\"noreferrer noopener\">regular expression<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/grep-command-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">grep &#8211; one of the most important commands like echo<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/basename-dirname-directory-name\/\" target=\"_blank\" rel=\"noreferrer noopener\">getting the basename and directory name of a file<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/date-command-in-linux-unix-with-practical-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">date command to find time date<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/touch-command-in-linux-unix-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">touch command<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/hard-links-and-soft-links-in-linux\/\" target=\"_blank\" rel=\"noreferrer noopener\">links in Linux<\/a><\/li>\n\n\n\n<li class=\"\"><a href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\">printf command in linux<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"\">If you have queries or suggestions, put them in the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.<\/p>\n","protected":false},"author":2,"featured_media":2664,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[58],"tags":[18,35],"class_list":["post-2639","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash","tag-command-line-tools","tag-core-linux-utilities"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create Shell Scripts in Linux\/Unix | SmartTech101<\/title>\n<meta name=\"description\" content=\"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Shell Scripts in Linux\/Unix | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-24T19:08:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-22T15:49:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"How to Create Shell Scripts in Linux\/Unix\",\"datePublished\":\"2023-03-24T19:08:50+00:00\",\"dateModified\":\"2024-02-22T15:49:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\"},\"wordCount\":1110,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1\",\"keywords\":[\"Command Line Tools\",\"core linux utilities\"],\"articleSection\":[\"bash\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\",\"url\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\",\"name\":\"How to Create Shell Scripts in Linux\/Unix | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2023-03-24T19:08:50+00:00\",\"dateModified\":\"2024-02-22T15:49:15+00:00\",\"description\":\"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"How to Create Shell Scripts in Linux\/Unix\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Shell Scripts in Linux\/Unix\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create Shell Scripts in Linux\/Unix | SmartTech101","description":"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.","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:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Shell Scripts in Linux\/Unix | SmartTech101","og_description":"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.","og_url":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/","og_site_name":"SmartTech101","article_published_time":"2023-03-24T19:08:50+00:00","article_modified_time":"2024-02-22T15:49:15+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"How to Create Shell Scripts in Linux\/Unix","datePublished":"2023-03-24T19:08:50+00:00","dateModified":"2024-02-22T15:49:15+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/"},"wordCount":1110,"commentCount":2,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1","keywords":["Command Line Tools","core linux utilities"],"articleSection":["bash"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/","url":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/","name":"How to Create Shell Scripts in Linux\/Unix | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1","datePublished":"2023-03-24T19:08:50+00:00","dateModified":"2024-02-22T15:49:15+00:00","description":"It is about how to create and run shell scripts in Linux and Mac. I will also talk about basic commands getting and setting variable values.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"How to Create Shell Scripts in Linux\/Unix"},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"How to Create Shell Scripts in Linux\/Unix"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2023\/03\/How-to-Create-Shell-Scripts-in-LinuxUnix.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2639"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=2639"}],"version-history":[{"count":5,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2639\/revisions"}],"predecessor-version":[{"id":3321,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/2639\/revisions\/3321"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/2664"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=2639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=2639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=2639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}