Skip to main content

Bash Scripting


Bash is a powerful Linux terminal application and bash scripting can be used to automate repetitive tasks easily. In this post, we will look at some basic bash scripting.


Bash scripting
[pre class="brush:bash"]
vim temp.sh

#!/bin/bash
echo “Hello world…”
Sleep 1
echo “How are you?”
read ans
echo “you typed $ans”

chmod +x temp.sh

./temp.sh[/pre]

How to run a bash script from anywhere
[pre class="brush:bash"]
# create a directory say "bin" under your home directory.
# update your path variable to include this bin directory.
#Put this in .profile or .bash_profle file to make it permanent.
export PATH=$PATH":$HOME/bin"
#or use the following if you want the directory to precedent system directories
PATH=$HOME/bin:$PATH;
# create a script say, "hello" and keep it in your bin directory.
#Give execute permission to the hello script.

#!/bin/bash
echo My first program

# from any directory, you simply type:
$ hello
My first program[/pre]

Comments

Popular posts from this blog

Advantages and Disadvantages of Electro-oculography (EOG)

In the previous post we looked at what is EOG? In this post we will look at the advantages and disadvantages of EOG.

How to Convert Excel Charts into High Resolution Images

Microsoft Excel is widely used to generate graphs and to analyse data due to its simple graphical user interface. Have you ever tried to convert the charts into images? If yes, you might have used "Print Screen" feature to easily convert the charts into images. However most of the scientific journals require the images in high resolution TIFF format. So in this post we will look at how to convert Microsoft Excel Charts/Graphs easily into high resolution images.

Online Radio Stations

Some of the popular Tamil radio stations are listed here. You can listen to those radios here.