

{"id":259195,"date":"2022-11-15T23:21:12","date_gmt":"2022-11-15T17:51:12","guid":{"rendered":"https:\/\/www.jigsawacademy.com\/?p=259195"},"modified":"2022-11-15T23:23:28","modified_gmt":"2022-11-15T17:53:28","slug":"an-advanced-guide-to-shell-scripting-in-unix","status":"publish","type":"post","link":"https:\/\/www.jigsawacademy.com\/blogs\/an-advanced-guide-to-shell-scripting-in-unix\/","title":{"rendered":"An Advanced Guide to Shell Scripting in Unix!"},"content":{"rendered":"<h3 aria-level=\"1\"><b><span data-contrast=\"auto\">Introduction<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:400,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">A shell script is a powerful tool that is used to automate a wide variety of tasks. A script is simply a text file containing a series of shell (command line) commands executed in order, one after the other. This allows the user to automate tasks that would otherwise have to be performed manually. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Generation of reports and performing complex administrative tasks is possible due to shell scripting. In addition, shell scripts can automate tasks that would otherwise have to be performed manually. This can save the user time and effort and make complex tasks easier. <\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"2\"><b><span data-contrast=\"auto\">What Is Shell Scripting?<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><b><span data-contrast=\"none\">Unix shell scripting<\/span><\/b><span data-contrast=\"none\"> uses a shell script by the Unix shell. A shell script is a program that provides a command-line interface (CLI) for interacting with the operating system. These are typically written in a text editor such as vi or emacs.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Shell scripts can automate various tasks, such as system administration, application installation, etc. They are also often used to provide a user interface for applications that don&#8217;t have one. For example, a shell script may also print a menu of options and execute the selected option.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">Developers write <\/span><b><span data-contrast=\"none\">shell scripts<\/span><\/b><span data-contrast=\"none\"> in a scripting language, a type of programming language designed to be easy to learn and use. The most popular scripting language for shell scripts is the Bourne shell, the default shell on many Unix-like systems. Other popular scripting languages include bash, Csh, and Ksh.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"2\"><b><span data-contrast=\"auto\">Types of Shells<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">There are two main categories of shells in Unix:<\/span><\/p>\n<p><b><span data-contrast=\"auto\">Bourne shell: <\/span><\/b><span data-contrast=\"auto\">The default prompt for a Bourne-type shell is the $ character.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><span data-contrast=\"auto\">C-Shell:<\/span><\/b><span data-contrast=\"auto\"> When using a C-type shell, the default prompt is the % character.<\/span><\/p>\n<p><span data-contrast=\"auto\">The following subcategories are included in The Bourne Shell:<\/span><\/p>\n<ul>\n<li><span data-contrast=\"auto\">Shelley&#8217;s Bourne (sh)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">Shelled korn (ksh)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">Shell for Bourne Again (bash)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">Shell POSIX (sh)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">The various C-type shells are as follows:<\/span><\/p>\n<ul>\n<li><span data-contrast=\"auto\">Shell C (csh)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<li><span data-contrast=\"auto\">TENEX\/TOPS Shell C (tcsh)<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559685&quot;:720,&quot;335559740&quot;:276,&quot;335559991&quot;:360}\">\u00a0<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"auto\">While working at the AT&amp;T Bell Labs in New Jersey in the middle of the 1970s, Stephen R. Bourne created the initial Unix shell. The Bourne shell is referred to as &#8220;the shell&#8221; because it was the first shell to arrive on Unix systems.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">The Bourne shell is commonly installed as \/bin\/sh in most Unix versions. Because of this, it is the preferred shell for creating scripts that can run on different Unix versions.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"2\"><b><span data-contrast=\"auto\">Features of Shell Scripting<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h2>\n<p><span data-contrast=\"none\">Given below are some of the capabilities of shell scripting:<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">1. Automation of Repetitive Tasks<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">If you regularly perform a task that requires a series of steps, you can use a shell script to automate the task. This can save you time and effort and help to ensure that the task is performed each time correctly.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">2. Launch and Control Applications<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">You can use a shell script to launch an application and then control how the application runs. This can include specifying the input and output files and the required options.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">3. Create, Modify, and Delete Files and Directories<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">A shell script can be used to create a new file and then add text to the file. You can also use a shell script to delete a file or modify an existing file.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">4. Manipulate Text Files<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">A shell script can be used to search for a particular word or phrase in a text file and then replace it with another word or phrase. You can also use a shell script to extract information from a text file or to convert a text file from one format to another.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">5. Generate Reports<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">You can use a shell script to generate a report that lists all the files in a directory or all the users on a system. You can also use a shell script to generate a report that summarises the usage of a system.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">6. Perform System Administration Tasks<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">It is possible to add a new user to a system or delete an existing user using a shell script. You can also use a shell script to change a user&#8217;s password or create a new group.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">7. Create, Modify, and Delete Users and Groups<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">You can use a shell script to create or delete a new user. You can also use a shell script to add a user or remove a user from a group.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">8. Manage File Permissions<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">A shell script can be used to grant read and write permission or deny read and write permission to a file. You can also use a shell script to change a file&#8217;s owner or the group of a file.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">9. Monitor System Performance<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">You can use a shell script to monitor the CPU usage of a system or to monitor the memory usage of a system. You can also use a shell script to monitor the disk usage system or to monitor the network usage of a system.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">10. Troubleshoot System Problems<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">You can use a shell script to check the configuration of a system or to find out what processes are running on a system. You can also use a shell script to determine why a system is not responding or to find out what is causing a system to crash.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"2\"><b><span data-contrast=\"auto\">Advantages of Shell Script<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h2>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">1. Automation of Repetitive or Tedious Tasks<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">If you find yourself performing the same task repeatedly, a shell script can save you a lot of time and effort. You can run the shell script by automating the task and letting it do the work for you.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">2. A Consistent Interface to a Complex System<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">If you have a complex system with many different components, a shell script can provide a consistent interface to the system. This can make it easier to use the system and reduce the learning curve.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">3. Perform System Administration Tasks<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripts can be used to automate system administration tasks. This can save you a lot of time and effort and help ensure that tasks are performed consistently.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">4. Create new Commands or Utilities<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">If you need a new command or utility, a shell script can be used to create it. This can be a great way to extend the functionality of the system.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">5. Extend the Functionality of Existing Commands or Utilities<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">If an existing command or utility is lacking in some way, a shell script can be used to extend its functionality. This can be a great way to add new features or fix existing problems.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h2 aria-level=\"2\"><b><span data-contrast=\"auto\">Disadvantages of Shell Script<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h2>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">1. Not Portable<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripts are not portable, which means they can only be used on the system where they were created. If you need to use a shell script on another system, you must port it to that system.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">2. Not as Fast as Compiled Programs<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripts are interpreted, which means they are slower than compiled programs. If speed is critical, consider using a compiled language.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">3. Not as Flexible as Compiled Programs<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripts are not as flexible as compiled programs. This means they can only be used for the tasks they were designed for. If you need to perform a task that is not supported by a shell script, you will need to use a different language.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">4. Not as Easy to Debug as Compiled Programs<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripts are not as easy to debug as compiled programs. This means that it can be more difficult to find and fix errors in a shell script.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"2\"><b><span data-contrast=\"auto\">Example of Shell Script<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:360,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Let&#8217;s say we write the test.sh script. Keep in mind that every script would end with .sh. The first thing you need to do in your script is to notify the system that a shell script is being started before adding anything else to it. The shebang syntax is used for this. For instance,<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"none\">#!\/bin\/sh<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">This instructs the system that the Bourne shell will run the next instructions. The # symbol and the! Symbols are referred to as hashes and bangs, respectively, which is why it is known as a shebang. You must include the shebang line before adding the commands to a script that contains these commands.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"none\">#!\/bin\/bash<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"none\">pwd<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"none\">ls<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">Extended Shell Scripts<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"auto\">There are a number of necessary constructs in shell scripts that instruct the shell environment on what to do and when to do it. Naturally, most scripts are more intricate than the ones mentioned.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">After all, the shell is a true programming language with variables, control structures, and other features. No matter how complex a script becomes, it is still nothing more than a series of commands that are run in order.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">The script follows uses the read command, which assigns the keyboard input value to the variable PERSON before printing it on STDOUT.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">#!\/bin\/sh<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\"># Author : john doe<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\"># Script follows here:<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">echo &#8220;What is your name?&#8221;<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">read PERSON<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">echo &#8220;Hello, $PERSON&#8221;<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><span data-contrast=\"auto\">Sample Run Script<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:200,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">$.\/test.sh<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">What is your name?<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">John doe<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><b><i><span data-contrast=\"auto\">Hello, john doe<\/span><\/i><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:0,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">$<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:200,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n<h3 aria-level=\"3\"><b><span data-contrast=\"auto\">Conclusion<\/span><\/b><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559738&quot;:320,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/h3>\n<p><span data-contrast=\"none\">Shell scripting makes business-grade task automation possible. While shell scripts\u00a0have some disadvantages, such as not being as fast as compiled programs, their advantages far outweigh these disadvantages. Shell scripts are easy to learn and use and can perform various simple and complex tasks.<\/span><span data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:240,&quot;335559740&quot;:276}\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction\u00a0 A shell script is a powerful tool that is used to automate a wide variety of tasks. A script is simply a text file containing a series of shell (command line) commands executed in order, one after the other. This allows the user to automate tasks that would otherwise have to be performed manually. [&hellip;]<\/p>\n","protected":false},"author":2640,"featured_media":259199,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1496,1505],"tags":[],"form":[494],"acf":[],"_links":{"self":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/259195"}],"collection":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/users\/2640"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/comments?post=259195"}],"version-history":[{"count":1,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/259195\/revisions"}],"predecessor-version":[{"id":259200,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/259195\/revisions\/259200"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/media\/259199"}],"wp:attachment":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/media?parent=259195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/categories?post=259195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/tags?post=259195"},{"taxonomy":"form","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/form?post=259195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}