<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: El-karece Asiedu</title>
    <description>The latest articles on DEV Community by El-karece Asiedu (@karecea).</description>
    <link>https://dev.to/karecea</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F690110%2F96a2757d-f1b7-45fb-814a-18400d05bbbc.jpeg</url>
      <title>DEV Community: El-karece Asiedu</title>
      <link>https://dev.to/karecea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karecea"/>
    <language>en</language>
    <item>
      <title>Bash Scripting: An Introduction</title>
      <dc:creator>El-karece Asiedu</dc:creator>
      <pubDate>Thu, 17 Nov 2022 16:26:35 +0000</pubDate>
      <link>https://dev.to/karecea/bash-scripting-an-introduction-19ml</link>
      <guid>https://dev.to/karecea/bash-scripting-an-introduction-19ml</guid>
      <description>&lt;p&gt;Bash stands for Bourne Again Shell because it is an improvement on the previously existing shell. This blog post is to understand the whole concept of bash and get why developers really use bash! This is just the beginning so it will cover the basics.&lt;/p&gt;

&lt;p&gt;Bash is used on linux OS. I will be using Mac OS in this. blog post the default shell is zsh. To use bash installed some dependencies to get started.&lt;/p&gt;

&lt;p&gt;Bash can be used for virtual machines, deploying services and automating basic tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  write a bash script with me
&lt;/h2&gt;

&lt;p&gt;Open terminal and type the following commands to change your file directory and move from zsh to bash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8nfcc7vp1ccxrsrmrnt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8nfcc7vp1ccxrsrmrnt.png" alt="Image description" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To access bash terminal, type these commands. Notice the change to bash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jvbe4hrd84iymlgxl69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jvbe4hrd84iymlgxl69.png" alt="Image description" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a new file as .sh file for scripting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbk3ds6fu6bn0tuyu6li.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbk3ds6fu6bn0tuyu6li.png" alt="Image description" width="800" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use "nano" to open the script in terminal and start typing bash script.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftvwhb6sip8tly3y3so3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftvwhb6sip8tly3y3so3g.png" alt="Image description" width="800" height="510"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Every bash script should begin with this code below known as "Shebang".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!# /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now type the bash script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!# /bin/bash
echo "Good morning Karece!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Select Ctrl + x on your keyboard then select "y" also on your keyboard, then enter to save the script.&lt;/p&gt;

&lt;p&gt;Check permissions. And make your script executable.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls -al&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7xxkzungukv55201250.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe7xxkzungukv55201250.png" alt="Image description" width="546" height="38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now run your bash script using.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F392iok91gmt906miff9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F392iok91gmt906miff9v.png" alt="Image description" width="420" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's the first bash script!&lt;/p&gt;

&lt;p&gt;Another bash script you can try.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; #!/bin/bash

name=$1
compliment= $2

user=$(whoami)
whereami=$(pwd)
date=$(date)

echo "Good morning $name!!"
sleep 1
echo "You're looking good today $name!"
sleep 1
echo "You have the best $2 ever $name!"

sleep 2

echo "You are currently logged in as $user and you are in the directory 
$whereami. Also today is: $date"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./nameofscript Karece Code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some helpful videos can be found &lt;a href="https://www.youtube.com/playlist?list=PLIhvC56v63IKioClkSNDjW7iz-6TFvLwS" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Done!&lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
  </channel>
</rss>
