The pipeline instruction (|) comes to rescue, when chaining several commands.
Linux commands have their own syntax, Linux won’t forgive you whatsoever is the mistakes. If you get a command wrong, you won’t flunk or damage anything, but it won’t work.
#!/bin/sh – It is called shebang.
It is written at the top of a shell script and it passes the instruction to the program /bin/sh.
To learn more on Linux Shell Scripting please visit our Linux Shell Scripting course here.
Shell script is just a simple text file with “.sh” extension, having executable permission.
Process of writing and executing a script
You can use Azure to create your own Linux servers. You can read Azure Introduction from here.
#!/bin/bash
# My first script echo
"Hello World!"
#!/bin/bash (is the shebang.)
# My first script (is comment, anything following '#' is a comment)
echo “Hello World!” #(is the main part of this script)
Output:
#! /bin/bash
echo "Hello $USER"
echo "Hey i am" $USER "and will be telling you about the current processes"
echo "Running processes List"
ps
Output:
Moving to, write our third and last script for this article. This script acts as an interactive script. Why don’t you, yourself execute this simple yet interactive script and tell us how you felt.
#! /bin/bash
echo "Hey what's Your First Name?";
read a;
echo "welcome Mr./Mrs. $a, would you like to tell us, Your Last Name";
read b;
echo "Thanks Mr./Mrs. $a $b for telling us your name";
echo "*******************"
echo "Mr./Mrs. $b, it's time to say you good bye"
Output: