Some Basic Programming Thru The Linux CLI - Post #39
LUMPIA anyone? One of my favorite pinoy food……...
TO BE AN EXPERT IS TO BE A DUMMY FIRSTLY
As we continue on with the tutorials on the advantages of the LINUX desktop, it is high time to teach some basic programming skills using the linux cli, and in particular, the B.A.S.H. (Bourne-Again SHell). All TERMINAL screenshots as previously presented on my previous posts bear the BASH shell, the default cli language behind the TERMINAL program on most linux distributions, including Linux Mint as sampled.
Here it is again:
DISPLAY SOME TEXTS ON THE TERMINAL THRU PROGRAMMING
Basic dummy tasks will always involve some text display capabilities as programmatically displayed, this is how we will do this:
-1. Open the TERMINAL program to be able to use the default BASH programming. In this exercise, we will display on the screen these very words:
“I am @LIGHTINGMACSTEEM, and this is BASH”
-2. Once the TERMINAL program is opened, issue the commands exactly in order to be able to do the same as what I had shown on the above screenshot as per instruction #1:
*vim sampletextdisplay
*i ←------------- this is letter small I
*type the words exactly as I write, line by line:
#!/bin/sh
echo “I am @LIGHTINGMACSTEEM, and this is BASH”
*ESC + Shift + zz ----------- this Escape + Shift + letter z then letter z again
Every line should be followed by the ENTER key of the keyboard except the last command (with the double zz letter as typed).
--
-3. As you press the last ENTER keyboard input, you just made a basic programming script in the BASH language. To check if you really are succesful in writing the said program and naming it “sampletextdisplay”, issue this command:
*cat sampletextdisplay
Screenshot of such “cat” command below:
--
-4. As the last step before one can run a BASH script, issue the command below:
*chmod 700 sampletextdisplay
The command above will enable the “sampletextdisplay” to become executable, in simplest terms, we are telling the BASH environment that the said script can be auto-executed using the BASH language.
--
-5. Once steps #1 to #4 easy steps are done, issue the command below to finally run your program and display the intended texts as programmed:
*./sampletextdisplay ←-------- this is “dot + forward slash + sampletextdisplay”
--
As these tutorials are clearly intended for programming dummies, the displayed texts as run succesfully clearly indicates a SUCCESS in your first programming steps using the echo command as interpreted by the BASH programming environment.
Be encouraged, as I also started at this level to be honest, although that is about 20 years ago. You can do it in less than a year.