Shell Scripts
Shell scripts are sequential collection of commands that generally represent a workflow.
Shell scripts can use other commands as building blocks.
Example
Suppose that occasionally you want the system to tell you some simple information, like your user id, the current directory and its content, and display the current date. To avoid typing this sequence of commands every time you want to know this information, you can compose a short script that execute the commands in a specific order.
Open a text editor (e.g. nano).
Type the sequence of commands to execute in the specific order they should be executed.
clear
echo Today date is:
date
echo
echo Your current directory is:
pwd
echo
echo The files in your current directory are:
ls -lt
echo
echo Have a nice day!

Save the file by giving to the script a meaningful name, for example info.sh.

Execute the command by invoking your shell (e.g. bash) followed by the script name. If you don't know what shell you are running, type "echo $SHELL" at the prompt.
bash info.sh

Last updated
Was this helpful?