<?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: Mohd Saquib Mansoori</title>
    <description>The latest articles on DEV Community by Mohd Saquib Mansoori (@mohdsaquib114).</description>
    <link>https://dev.to/mohdsaquib114</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%2F1089594%2F2b178d3d-c08a-4764-80d4-ee8dd7fdfe4e.jpeg</url>
      <title>DEV Community: Mohd Saquib Mansoori</title>
      <link>https://dev.to/mohdsaquib114</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohdsaquib114"/>
    <language>en</language>
    <item>
      <title>Creating a small project on Counting Using Bash Scripting</title>
      <dc:creator>Mohd Saquib Mansoori</dc:creator>
      <pubDate>Sat, 22 Jul 2023 10:00:07 +0000</pubDate>
      <link>https://dev.to/mohdsaquib114/creating-a-small-project-on-counting-using-bash-scripting-4c6d</link>
      <guid>https://dev.to/mohdsaquib114/creating-a-small-project-on-counting-using-bash-scripting-4c6d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Title: Building a Simple Timer Project Using Bash Scripting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
In the world of programming, mastering various languages is essential for expanding your skills and enhancing problem-solving abilities. Bash scripting is one such powerful tool that comes in handy for automating tasks, managing processes, and creating small projects. In this blog, we'll explore how to build a simple yet practical timer project using Bash scripting. Whether you're a beginner or an experienced developer, this project will not only be a fun challenge but also a great way to strengthen your Bash skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;br&gt;
Before diving into the project, make sure you have basic knowledge of Bash scripting and a Linux or macOS environment. Bash is a popular shell and scripting language that comes pre-installed on most Unix-based systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project Overview:&lt;/strong&gt;&lt;br&gt;
The goal of this project is to create a timer that allows users to set a specific time interval and receive a notification when the timer expires. We'll use the &lt;code&gt;sleep&lt;/code&gt; command to achieve this, along with some basic user input and output handling in Bash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Getting Started&lt;/strong&gt;&lt;br&gt;
To begin, open your terminal and create a new file called &lt;code&gt;timer.sh&lt;/code&gt; using your favorite text editor. This file will contain the Bash script that defines the timer's functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Setting the Timer&lt;/strong&gt;&lt;br&gt;
In this step, we'll ask the user to input the desired time interval for the timer. We'll use the &lt;code&gt;read&lt;/code&gt; command to prompt the user for input and store it in a variable.&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Welcome to the Bash Timer!"&lt;/span&gt;

&lt;span class="c"&gt;# Ask the user to enter the time interval&lt;/span&gt;
&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Enter the time in seconds: "&lt;/span&gt; time_interval
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Timer Logic&lt;/strong&gt;&lt;br&gt;
With the user's input, we'll implement the timer logic using the &lt;code&gt;sleep&lt;/code&gt; command. The &lt;code&gt;sleep&lt;/code&gt; command suspends the script's execution for a specified number of seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check if the input is a positive integer&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$time_interval&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ ^[0-9]+&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Please enter a positive integer."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Display a confirmation message to the user&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Timer set for &lt;/span&gt;&lt;span class="nv"&gt;$time_interval&lt;/span&gt;&lt;span class="s2"&gt; seconds. Press Ctrl+C to stop the timer."&lt;/span&gt;

&lt;span class="c"&gt;# Start the timer&lt;/span&gt;
&lt;span class="nb"&gt;sleep&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$time_interval&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Timer expires - display the notification&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Timer expired! Time's up!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Make the Script Executable&lt;/strong&gt;&lt;br&gt;
Before we can run the script, we need to make it executable using the &lt;code&gt;chmod&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x timer.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Run the Timer&lt;/strong&gt;&lt;br&gt;
You're now ready to run the timer! Execute the script in your terminal by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./timer.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Congratulations! You've successfully built a simple timer project using Bash scripting. This project may seem modest, but it lays the groundwork for more complex and useful applications. Feel free to expand this project by adding features like sound notifications, multiple timers, or integrating it with other scripts. With Bash scripting, the possibilities are endless!&lt;/p&gt;

&lt;p&gt;Remember, practice is key to mastering any programming language. So, keep exploring, experimenting, and building more projects to enhance your skills and become a proficient developer.&lt;/p&gt;

&lt;p&gt;If there is any thing wrong or is not correct, let me know.&lt;/p&gt;

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