Bash Scripting

# bash script for easier change of CD

#!/bin/bash
umount /dev/cdrom
echo -n “Press the enter key to continue.”
read
mount -t iso9660 /dev/cdrom /cdrom

Source: (Johnson 2009, p. 12)

Comment is the first line and the one that follows is a special comment which is not ignored by bash. The first line is conventional to all commands while the second line shows the type of command script and it does ensure that there is execution of the script in the bash. The standard command for unmounting the CD is represented by the third line while the next line will display the prompt. The fifth line reads the commands from the standard input to mount the CD-ROM drive.

If there is existence of scripts, its execution can be done in several ways. The first way is done through enter of command “chmod +x remount,” which will change the permission of the file and make it executable. Another way is through entering “bash remount” command which will start a new shell and inform it to make an execution of the command that is available in the file for remounting (Michael 2008, p. 6). The last way is through running a command that informs the shell script that it should make an execution of all commands that are in a file passed by an argument. The symbol “/” is normally displayed when searching for a bash command line in a $PATH, which are series of directories. The bash will only search for the particular directory that has the command to be executed.

Uses of Bash Scripting

Bash has useful interactive features for communicating between different programs. Bash scripting is incredibly important in the administration of systems, deployments, web applications and data crunching. Bash scripting allows the automation of command line tasks through the use of the same language which is scripting language (Michael 2008, p. 9). This makes it easier to be used within the shell. Its high-level language makes it quick for navigation around the hardware. Bash scripting also gives an understanding of the way Unix and other important aspects work in hardware (Parker 2011, p.16). Bash is significant for myriad administrative tasks and makes it easier in finding scripts which would cover the most complicated scenarios. It therefore handles them in a graceful manner.

Leave a Reply

Your email address will not be published. Required fields are marked *