{" "} Programming Help by Programmers hub

Bash programming language

Bash is a shell programming language which means writing a code that shell executes. The Bash is a most common Linux shell. The name of the Bash comes from the “Bourne Again Shell”. There are many shell programming languages but people want to stick to Bash because it provide the platform interdependency and flexibility to the program. The features of the Bash programming keeps on enhance with time as some modern features add to shell e.g allows you to open more than one shall at a time and colored directory listing.

Steps to write and execute a shell program

  • Choose text editor and write special first line #!/bin/bash
  • Write the command echo to display text       echo”hello,world.”
  • Save the file 
  • Open shell and write the command               $chmod +x myscript.sh
  • Execute the script                                    $ ./myscript.sh 

Shell script basics

  • The file must contain the special first line    #!/bin/bas
  • Locate the bash shell executable                $ whereis bash
  • Change the permissions of file                    $ whereis bash
  • Execution of shell scripting                        $ ./scriptname.sh

Bash code example

{`
$cat ~/.bash_profile
hname=hostname
echo "Welcome on $hname."
echo -e "Kernel Details: " uname -smr
echo -e "bash --version "
echo -ne "Uptime: "; uptime
echo -ne "Server time : "; date
`}