<?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: zaira</title>
    <description>The latest articles on DEV Community by zaira (@hira_zaira).</description>
    <link>https://dev.to/hira_zaira</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%2F960086%2F2dc5cc5a-0846-43cb-80a8-f97de7d03299.jpg</url>
      <title>DEV Community: zaira</title>
      <link>https://dev.to/hira_zaira</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hira_zaira"/>
    <language>en</language>
    <item>
      <title>JavaScript "textContent" vs "innerHTML"</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Tue, 25 Jul 2023 10:50:01 +0000</pubDate>
      <link>https://dev.to/hira_zaira/javascript-textcontent-vs-innerhtml-2mif</link>
      <guid>https://dev.to/hira_zaira/javascript-textcontent-vs-innerhtml-2mif</guid>
      <description>&lt;p&gt;In JavaScript, both the &lt;code&gt;innerHTML&lt;/code&gt; and &lt;code&gt;textContent&lt;/code&gt; can be used to manipulate the text inside HTML elements.However, there is a slight difference between the two.&lt;/p&gt;

&lt;p&gt;Let's see that difference in this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;textContent&lt;/code&gt; vs &lt;code&gt;innerHTML&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;textContent&lt;/code&gt; is used to set the text between any tag.You pass the text as the string.&lt;/p&gt;

&lt;p&gt;Whereas, &lt;code&gt;innerHTML&lt;/code&gt; is used to pass any other HTML as the content of an HTML tag.&lt;/p&gt;

&lt;p&gt;For the upcoming examples, we will use this HTML&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Using innerHTML:&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;id = &lt;/span&gt;&lt;span class="s"&gt;"innerHTML"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Using textContent:&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;id = &lt;/span&gt;&lt;span class="s"&gt;"textContent"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example of &lt;code&gt;textContent&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;We have passed a string "Hello World" as the textual content of &lt;code&gt;h2&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;textContent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, passing  any HTML tags as a string won't render as HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PZPbM3q7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5ojy3m64sa4fr34vozo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PZPbM3q7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k5ojy3m64sa4fr34vozo.png" alt="Image description" width="404" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example of &lt;code&gt;innerHTML&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Here, we passed some additional HTML &lt;code&gt;&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;&lt;/code&gt; in between the &lt;code&gt;h2&lt;/code&gt; tags. That is why we got the output in italics&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;innerHTML&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;em&amp;gt;Hello World&amp;lt;/em&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wX0fMHYH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qh1s6p0xioh9bnl75fyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wX0fMHYH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qh1s6p0xioh9bnl75fyb.png" alt="Image description" width="378" height="121"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I hope you found this tutorial helpful. Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create a chessboard using CSS Grid</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Wed, 12 Jul 2023 14:09:40 +0000</pubDate>
      <link>https://dev.to/hira_zaira/create-a-chessboard-using-css-grid-3iil</link>
      <guid>https://dev.to/hira_zaira/create-a-chessboard-using-css-grid-3iil</guid>
      <description>&lt;p&gt;It is fairly easy to create a Chessboard using just CSS Grid. With a CSS grid, you can create a grid-based layout pretty much like an actual chess board.&lt;/p&gt;

&lt;p&gt;In this article, we would use only HTML and CSS to create a chessboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1: Define the grid container.
&lt;/h2&gt;

&lt;p&gt;Here, we have set the width of the container to be &lt;code&gt;800px&lt;/code&gt;.&lt;br&gt;
We have enabled the grid display using &lt;code&gt;display: grid;&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;800px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step2: Define rows and columns using &lt;code&gt;fr&lt;/code&gt;- fractional ratios
&lt;/h2&gt;

&lt;p&gt;Here, we have defined 8 columns and 8 rows, each equal to 1 &lt;code&gt;fr&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;800px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step3: Define classes for alternating boxes.
&lt;/h2&gt;

&lt;p&gt;Now, we can define the height and width of each box.&lt;br&gt;
As the container width was &lt;code&gt;800px&lt;/code&gt;, we can create each box of &lt;code&gt;800/8=100px&lt;/code&gt; each.&lt;br&gt;
Note that the chessboard grid is 8x8.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;


&lt;span class="nc"&gt;.white&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.black&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here is the complete code:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/rancid_beet/embed/RwqxJyR?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I hope you found this tutorial helpful. Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/" rel="noopener noreferrer"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--lTK5eo7c--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_800%2Fhttps%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfwvazd9y2xuvmdl1746.png" alt="Buy me a coffee"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
    </item>
    <item>
      <title>How to Use Linux on a Windows Machine – 5 Different Approaches</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Tue, 11 Jul 2023 14:12:49 +0000</pubDate>
      <link>https://dev.to/hira_zaira/how-to-use-linux-on-a-windows-machine-5-different-approaches-2he7</link>
      <guid>https://dev.to/hira_zaira/how-to-use-linux-on-a-windows-machine-5-different-approaches-2he7</guid>
      <description>&lt;p&gt;As a developer, you might need to run both Linux and Windows side by side. Luckily, there are a number of ways you can get the best of both worlds without getting different computers for each operating system.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore a few ways to use Linux on a Windows machine. Some of them are browser-based or cloud-based that do not need any installation prior to using them.&lt;/p&gt;

&lt;p&gt;Here are the methods we'll be discussing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Dual boot&lt;/li&gt;
&lt;li&gt;  Windows Subsystem for Linux (WSL)&lt;/li&gt;
&lt;li&gt;  Virtual Machines (VM)&lt;/li&gt;
&lt;li&gt;  Browser-based solutions&lt;/li&gt;
&lt;li&gt;  Cloud-based solutions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option 1: "Dual-boot" Linux + Windows
&lt;/h2&gt;

&lt;p&gt;With dual boot, you can install Linux alongside Windows on your computer, allowing you to choose which operating system to use at startup.&lt;/p&gt;

&lt;p&gt;This requires partitioning your hard drive and installing Linux on a separate partition. With this approach, you can only use one operating system at a time.&lt;/p&gt;

&lt;p&gt;If this sounds like the way you want to go,  &lt;a href="https://www.freecodecamp.org/news/how-to-dual-boot-windows-10-and-ubuntu-linux-dual-booting-tutorial/"&gt;here is a useful tutorial&lt;/a&gt;  on setting up dual boot on Windows 10.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 2: Use Windows Subsystem for Linux (WSL)
&lt;/h2&gt;

&lt;p&gt;Windows Subsystem for Linux provides a compatibility layer that lets you run Linux binary executables natively on Windows.&lt;/p&gt;

&lt;p&gt;Using WSL has some advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  The setup for WSL is simple and not time consuming.&lt;/li&gt;
&lt;li&gt;  It is lightweight compared to VMs where you have to allocate resources from the host machine.&lt;/li&gt;
&lt;li&gt;  You don't need to install any ISO or virtual disc image for Linux machines which tend to be heavy files.&lt;/li&gt;
&lt;li&gt;  You can use Windows and Linux side by side.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this sounds like the right option for you,  &lt;a href="https://www.freecodecamp.org/news/how-to-install-wsl2-windows-subsystem-for-linux-2-on-windows-10/"&gt;here is a detailed guide&lt;/a&gt;  on how to install and use WSL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 3: Use a Virtual Machine (VM)
&lt;/h2&gt;

&lt;p&gt;A virtual machine (VM) is a software emulation of a physical computer system. It allows you to run multiple operating systems and applications on a single physical machine simultaneously. Here's a detailed explanation of VMs:&lt;/p&gt;

&lt;p&gt;You can use virtualization software such as Oracle VirtualBox or VMware to create a virtual machine running Linux within your Windows environment. This allows you to run Linux as a guest operating system alongside Windows.&lt;/p&gt;

&lt;p&gt;VM software provides options to allocate and manage hardware resources for each VM, including CPU cores, memory, disk space, and network bandwidth. You can adjust these allocations based on the requirements of the guest operating systems and applications.&lt;/p&gt;

&lt;p&gt;Here are some of the options available for virtualization:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://www.virtualbox.org/"&gt;Oracle virtual box&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://multipass.run/"&gt;Multipass&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://www.vmware.com/content/vmware/vmware-published-sites/us/products/workstation-player.html.html"&gt;VMware workstation player&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Option 4: Use a Browser-based Solution
&lt;/h2&gt;

&lt;p&gt;Browser based solutions are particularly useful for quick testing, learning, or accessing Linux environments from devices that don't have Linux installed.&lt;/p&gt;

&lt;p&gt;You can either use online code editors or web based terminals to access Linux. Note that you usually don't have full administration privileges in these cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Online code editors
&lt;/h3&gt;

&lt;p&gt;Online code editors offer editors with built-in Linux terminals. While their primary purpose is coding, you can also utilize the Linux terminal to execute commands and perform tasks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://replit.com/"&gt;Replit&lt;/a&gt; is an example of an online code editor, where you can write your code and access the Linux shell at the same time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jGslf--K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/replit.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jGslf--K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/replit.gif" alt="replit" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Replit provides a code editor and a Linux shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Web-based Linux terminals
&lt;/h3&gt;

&lt;p&gt;Online Linux terminals allow you to access a Linux command-line interface directly from your browser. These terminals provide a web-based interface to a Linux shell, enabling you to execute commands and work with Linux utilities.&lt;/p&gt;

&lt;p&gt;One such example is  &lt;a href="https://jslinux.org/"&gt;JSLinux&lt;/a&gt;. The screenshot below shows a ready to use Linux environment:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BmehtZ1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/jslinux.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BmehtZ1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/jslinux.gif" alt="jslinux" width="800" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Accessing Linux via JSLinux&lt;/p&gt;

&lt;h2&gt;
  
  
  Option 5: Use a Cloud-based Solution
&lt;/h2&gt;

&lt;p&gt;Instead of running Linux directly on your Windows machine, you can consider using cloud-based Linux environments or virtual private servers (VPS) to access and work with Linux remotely.&lt;/p&gt;

&lt;p&gt;Services like Amazon EC2, Microsoft Azure, or DigitalOcean provide Linux instances that you can connect to from your Windows computer. Note that some of these services offer free tiers, but they are not usually free in the long run.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Choose the Correct Method
&lt;/h2&gt;

&lt;p&gt;The choice is totally dependent on your use case. But there are some factors that may help you decide which option works the best for you. Let's discuss them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Access level/elevated privilege: If you require full administrative privileges, it is better to skip the browser-based solutions. WSL, dual booting, VMs, and cloud-based solutions provide you with full administrative control.&lt;/li&gt;
&lt;li&gt;  Cost: Cloud-based solutions offer services against a subscription fee. This cost varies depending on the choice of operating system, hardware specs of the machine, traffic, and so on. If you are on a tight budget, cloud-based solutions might not be the best.&lt;/li&gt;
&lt;li&gt;  Scalability: If you are just starting, but plan to do resource exhaustive development in the future, you can always scale up the physical specs of your machine. Some options that support upgrading are cloud-based solutions and VMs. You can add more processors or increase the RAM as per your needs.&lt;/li&gt;
&lt;li&gt;  Current system's hardware specs: If your current system has lower RAM and storage, running VMs can make the system heavy. It would be better to opt for cloud-based or browser based solutions.&lt;/li&gt;
&lt;li&gt;  Switching: If you don't plan to use Windows and Linux side by side, dual-boot can be a really good option. It offers a complete and focused Linux experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Setup
&lt;/h2&gt;

&lt;p&gt;I am using Ubuntu VM installed through VMWare workstation player. It is doing a great job as I can frequently switch between two operating systems. It was also simple to setup and I can enjoy the admin privileges as well!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gd89wXn4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/my-set.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gd89wXn4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/06/my-set.gif" alt="my-set" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;I hope you found this article helpful. What’s your favorite thing you learned from this tutorial? I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;. 📧&lt;/p&gt;

&lt;p&gt;See you in the next tutorial, happy coding 😁&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Flex-box layout properties and live demo</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Wed, 05 Jul 2023 17:30:31 +0000</pubDate>
      <link>https://dev.to/hira_zaira/flex-box-layout-properties-and-live-demo-1kc5</link>
      <guid>https://dev.to/hira_zaira/flex-box-layout-properties-and-live-demo-1kc5</guid>
      <description>&lt;p&gt;Flexbox allows you to create a responsive layout that is flexible to the window size.&lt;/p&gt;

&lt;p&gt;In this post, I would share some of the important flex-box properties. There is also a demo at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ordering content with &lt;code&gt;order:0...&lt;/code&gt; using flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;[Child item property]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The higher the order, the later that item comes. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.child-item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case of a row layout, the higher order item is pushed to the extreme right.&lt;/p&gt;

&lt;p&gt;In case of a column layout, the higher order item is pushed to the very end.&lt;/p&gt;

&lt;p&gt;By default, the order is 0 of all items.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    .red {
      background-color: #eb4d4b;
    }

    .green {
      background-color: #6ab04c;
      order: 1;
    }

    .indigo {
      background-color: #30336b;
      order: 2;
    }     

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"green"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;order:1&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"indigo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;order:2&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;order:0&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h8v7txvf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukioln4zmzejd8ekpri0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h8v7txvf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukioln4zmzejd8ekpri0.png" alt="Image description" width="800" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Enabling wrap with &lt;code&gt;flex-wrap&lt;/code&gt; using flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;[Parent property]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Wrap allows you to control the content in horizontal layout when you run out of space.&lt;/p&gt;

&lt;p&gt;By default wrap is disabled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.container&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;flex-wrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt; &lt;span class="err"&gt;|&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;wrap&lt;/code&gt; is enabled, the items are pushed to the next line, if the screen is shrunk and space runs out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wiICdWIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54bab0owudp1j38m96io.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wiICdWIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54bab0owudp1j38m96io.png" alt="Image description" width="800" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Justifying content using flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;[Parent property]&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content: flex-start;&lt;/code&gt;: Items are bunched up to the left.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XsCiPt1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk3icnv18pmpjyu3x1ot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XsCiPt1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fk3icnv18pmpjyu3x1ot.png" alt="Image description" width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content: flex-end;&lt;/code&gt;: Items are bunched up to the right.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GcYlaK76--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ec2tvpdj4bfd5pmrea8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GcYlaK76--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ec2tvpdj4bfd5pmrea8.png" alt="Image description" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content: center;&lt;/code&gt;: Items are aligned to the  center.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hysOzMP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3knpboip0gsa4m9bfdh2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hysOzMP8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3knpboip0gsa4m9bfdh2.png" alt="Image description" width="800" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content: space-between;&lt;/code&gt;: Items have space between them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--117mRicR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jh35aebunps7ph4951rb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--117mRicR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jh35aebunps7ph4951rb.png" alt="Image description" width="800" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Aligning content across a container using flexbox
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;[Parent property]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For the &lt;code&gt;align-items&lt;/code&gt; to properly work, you need to set the height of the container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;align-items: flex-start;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2wN9tRFy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78erdweoo6kpm5z4fr9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2wN9tRFy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78erdweoo6kpm5z4fr9a.png" alt="Image description" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;align-items: flex-end;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hnkjX9qk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tthpcuj8g976rf9go8vb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hnkjX9qk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tthpcuj8g976rf9go8vb.png" alt="Image description" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;align-items: center;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B5SvyaiZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10hmucx3xbg91rhnlyta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B5SvyaiZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10hmucx3xbg91rhnlyta.png" alt="Image description" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;You can view a live preview of the flexbox layout concepts in this &lt;a href="https://zairahira.github.io/flex-box/"&gt;link&lt;/a&gt;.&lt;br&gt;
Feel free to experiment and play around :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I hope you found this tutorial helpful. Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dYYL6zw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--lTK5eo7c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfwvazd9y2xuvmdl1746.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>frontend</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Media Queries in CSS</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Sun, 02 Jul 2023 11:02:20 +0000</pubDate>
      <link>https://dev.to/hira_zaira/media-queries-in-css-3ipl</link>
      <guid>https://dev.to/hira_zaira/media-queries-in-css-3ipl</guid>
      <description>&lt;p&gt;A responsive website is a website that adapts according to its target device. For example a responsive website would adapt its layout to suit a laptop, a phone and a tablet. A phone has a smaller display, so a responsive website might make the font-size a bit bigger in smaller screens. &lt;/p&gt;

&lt;p&gt;But how do you do that? You can use media queries in your CSS to explicitly tell your website to change according to the screen size.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Targeting smaller screens with media queries&lt;/li&gt;
&lt;li&gt;Targeting larger screens with media queries&lt;/li&gt;
&lt;li&gt;Targeting a screen range using media queries&lt;/li&gt;
&lt;li&gt;See media queries in action&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Targeting smaller screens with media queries
&lt;/h2&gt;

&lt;p&gt;Let's discuss an example of defining media queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="c"&gt;/*
CSS for screens equal to or below 600px
*/&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, &lt;code&gt;600px&lt;/code&gt; is the breaking point. This means that you are targeting screen sizes equal to or below &lt;code&gt;600px&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the code below, any screen equal to or below 600px would have its background set to red.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Targeting larger screens with media queries
&lt;/h2&gt;

&lt;p&gt;In the below, example &lt;code&gt;900px&lt;/code&gt; is the breaking point. It is targeting screens whose width is at least &lt;code&gt;900px&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;900px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="c"&gt;/*
CSS for screens equal to or above 900px
*/&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the below example, any screen greater than &lt;code&gt;900px&lt;/code&gt; would have its background set to green.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;900px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Targeting a screen range using media queries
&lt;/h2&gt;

&lt;p&gt;The below code targets any screen greater than &lt;code&gt;600px&lt;/code&gt; and smaller than &lt;code&gt;900px&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;900px&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;

  &lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;burlywood&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  See media queries in action
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="//zairahira.github.io/media-queries/"&gt;this link&lt;/a&gt; to see media queries in action! Adjust the screen size and see how media queries are being applied!&lt;/p&gt;

&lt;p&gt;To review the code, go to &lt;a href="https://github.com/zairahira/media-queries"&gt;this &lt;/a&gt;GitHub repo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8s1sDy0M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryp25yxv2fnoi032xz3u.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8s1sDy0M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryp25yxv2fnoi032xz3u.gif" alt="Image description" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrapping up!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this tutorial helpful. Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dYYL6zw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--lTK5eo7c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfwvazd9y2xuvmdl1746.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>css</category>
      <category>programming</category>
    </item>
    <item>
      <title>Display in CSS</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Tue, 27 Jun 2023 11:04:54 +0000</pubDate>
      <link>https://dev.to/hira_zaira/display-in-css-3mol</link>
      <guid>https://dev.to/hira_zaira/display-in-css-3mol</guid>
      <description>&lt;p&gt;In this article, we would discuss the three ways that elements can be displayed on the web page. The three methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inline&lt;/li&gt;
&lt;li&gt;Block&lt;/li&gt;
&lt;li&gt;Inline-block&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Table of contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Inline display in CSS&lt;/li&gt;
&lt;li&gt;Block display in CSS&lt;/li&gt;
&lt;li&gt;Inline-block display in CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Inline display in CSS
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;span&lt;/code&gt; by default has the &lt;code&gt;inline&lt;/code&gt; display. This means that a &lt;code&gt;span&lt;/code&gt; element would stay on the same line where it was declared. Two spans declared together, would always stay on the same line.&lt;/p&gt;

&lt;p&gt;Other html elements such as a &lt;code&gt;div&lt;/code&gt; are block level elements by default. This means that each &lt;code&gt;div&lt;/code&gt; goes to a separate line and takes full width of the screen.&lt;/p&gt;

&lt;p&gt;You can make a &lt;code&gt;div&lt;/code&gt; inline like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost all other elements besides &lt;code&gt;span&lt;/code&gt; are &lt;code&gt;block&lt;/code&gt; by default.&lt;/p&gt;

&lt;p&gt;Note that, you cannot set the height and width of inline elements. they take the space as much as the content inside needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Block display in CSS
&lt;/h2&gt;

&lt;p&gt;Block elements take full width of the page. Block elements force the next element to go to the next line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N5gsv18K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7atixj9d9y2bb8c5a45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N5gsv18K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7atixj9d9y2bb8c5a45.png" alt="Image description" width="800" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can make them appear on the same line using this CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.blue&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.yellow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_KDsNsz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5i3nq9vojtauv1p1e9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_KDsNsz6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5i3nq9vojtauv1p1e9t.png" alt="Image description" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inline-block display in CSS
&lt;/h2&gt;

&lt;p&gt;An &lt;code&gt;inline-block&lt;/code&gt; uses the powers of both- &lt;code&gt;inline&lt;/code&gt; and &lt;code&gt;block&lt;/code&gt; displays:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;block&lt;/code&gt; allows us to set the height and width.&lt;br&gt;
&lt;code&gt;inline&lt;/code&gt; allows us to position elements in the same line.&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;inline-block&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS Positioning</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Thu, 22 Jun 2023 10:13:40 +0000</pubDate>
      <link>https://dev.to/hira_zaira/css-positioning-4a4j</link>
      <guid>https://dev.to/hira_zaira/css-positioning-4a4j</guid>
      <description>&lt;p&gt;CSS provides 4 ways through which you can position elements on your page.&lt;/p&gt;

&lt;p&gt;Let's study them all.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
Table of contents

&lt;ul&gt;
&lt;li&gt;Static positioning in CSS&lt;/li&gt;
&lt;li&gt;Relative positioning in CSS&lt;/li&gt;
&lt;li&gt;Absolute positioning in CSS&lt;/li&gt;
&lt;li&gt;Z-index&lt;/li&gt;
&lt;li&gt;Fixed positioning in CSS&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Static positioning in CSS
&lt;/h2&gt;

&lt;p&gt;This is the default positioning. This is the order in which elements are placed when you don't specify any particular position. It starts from the top-left corner of the page and continues down.&lt;/p&gt;

&lt;p&gt;To apply static positioning to an element in CSS, you don't need to add any specific positioning property. It is the default behavior. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;
&lt;span class="nc"&gt;.my-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* No specific positioning property needed */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Relative positioning in CSS
&lt;/h2&gt;

&lt;p&gt;This is the position &lt;strong&gt;relative to the default static positioning&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that this is not relative to any particular element as some may confuse it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Relative positioning introduces four offset properties that you can use to adjust the element's position:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;top&lt;/code&gt;: Specifies the distance from the top edge of the element's containing block to the top edge of the element.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bottom&lt;/code&gt;: Specifies the distance from the bottom edge of the element's containing block to the bottom edge of the element.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;left&lt;/code&gt;: Specifies the distance from the left edge of the element's containing block to the left edge of the element.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;right&lt;/code&gt;: Specifies the distance from the right edge of the element's containing block to the right edge of the element.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Absolute positioning in CSS
&lt;/h2&gt;

&lt;p&gt;Absolute positioning means that the elements get positioned relative to the nearest positioned ancestor OR relative to the top left corner of the page in case the ancestor is not using any position property.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ClrZVFch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsrc3x2qeidwfko3ubgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ClrZVFch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gsrc3x2qeidwfko3ubgh.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If there is no positioned ancestor, the default behavior is relative to the top-left corner of the webpage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To apply absolute positioning to an element in CSS, you can use the position property with the value absolute. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Z-index
&lt;/h3&gt;

&lt;p&gt;This is another aspect of the absolute positioning. It specifies which property goes on top of which.&lt;/p&gt;

&lt;p&gt;The default &lt;code&gt;z-index&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A lower &lt;code&gt;z-index&lt;/code&gt; means the element is behind.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;z-index:-1&lt;/code&gt; means, the element is at the farthest back of the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rLtMmH7v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joe8wyim2oh62rv1n6nq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rLtMmH7v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joe8wyim2oh62rv1n6nq.png" alt="Image description" width="673" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fixed positioning in CSS
&lt;/h2&gt;

&lt;p&gt;As the name suggests, the element stays in a fixed position even when you scroll down the page.&lt;/p&gt;

&lt;p&gt;Fixed positioning is commonly used for creating persistent elements that should remain in view regardless of scrolling, such as headers or sticky navigation menus. It's important to note that fixed positioning can sometimes cause layout issues or overlapping with other elements, so proper consideration should be given to ensure a good user experience.&lt;/p&gt;

&lt;p&gt;To apply fixed positioning to an element in CSS, you can use the position property with the value fixed. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.my-element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I hope you found this tutorial useful!&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dYYL6zw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--lTK5eo7c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfwvazd9y2xuvmdl1746.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Cascading in CSS</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Mon, 19 Jun 2023 14:31:39 +0000</pubDate>
      <link>https://dev.to/hira_zaira/cascading-in-css-2nkd</link>
      <guid>https://dev.to/hira_zaira/cascading-in-css-2nkd</guid>
      <description>&lt;p&gt;In CSS, it is possible to apply multiple styles to a single element. However, there is an order or precedence. One style always takes precedence over the other.&lt;/p&gt;

&lt;p&gt;In this article, we would learn how precedence works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Position
&lt;/h2&gt;

&lt;p&gt;The lower down a property is in the style sheet, the more important it is.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blueviolet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F28j5Wm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcc2bhu96gabiozfg93z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F28j5Wm_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wcc2bhu96gabiozfg93z.png" alt="applied blueviolet" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is another example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blueviolet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;orange&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and this is the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7rzJEpiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsz9wykdvq6hf9nniis9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7rzJEpiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsz9wykdvq6hf9nniis9.png" alt="applied orange" width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Specificity
&lt;/h2&gt;

&lt;p&gt;This rule works on how specifically an element is selected.&lt;br&gt;
Here is the order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;id&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;attribute&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;class&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;element&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This means that an &lt;code&gt;id selector&lt;/code&gt; would override an &lt;code&gt;attribute selector&lt;/code&gt; and a &lt;code&gt;class selector&lt;/code&gt; would override an element selector.&lt;/p&gt;

&lt;p&gt;Let's see an example HTML, we would apply styles to the &lt;code&gt;li&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;
&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all-items"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-items"&lt;/span&gt; &lt;span class="na"&gt;draggable=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all-items"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-items"&lt;/span&gt; &lt;span class="na"&gt;draggable=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Second&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all-items"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-items"&lt;/span&gt; &lt;span class="na"&gt;draggable=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all-items"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-items"&lt;/span&gt; &lt;span class="na"&gt;draggable=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fourth&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all-items"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-items"&lt;/span&gt; &lt;span class="na"&gt;draggable=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fifth&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule targeting the &lt;code&gt;id&lt;/code&gt; is applied, as it has the highest priority.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IEvoNtan--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8m1n11p3yo2fltcg2jt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IEvoNtan--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8m1n11p3yo2fltcg2jt.png" alt="id rule applied" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Type
&lt;/h2&gt;

&lt;p&gt;There are 3 ways in which you can apply styles to your HTML. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Internal style sheet: This method uses an internal style sheet, which means that you specify style in your HTML within the &lt;code&gt;style&lt;/code&gt; tags.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;External style sheet: In this approach, you link an external style sheet to your HTML using &lt;code&gt;&amp;lt;link rel="stylesheet" href="./style.css"&amp;gt;&lt;/code&gt; in the &lt;code&gt;head&lt;/code&gt; element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inline style: In this method, the style is applied using the style attribute inside an element. For example: &lt;code&gt;&amp;lt;h1 style="color: aliceblue;"&amp;gt;&amp;lt;/h1&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The order of precedence of applying styles is as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inline style.&lt;/li&gt;
&lt;li&gt;Internal style sheet &lt;/li&gt;
&lt;li&gt;External style sheet&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Importance- adding the &lt;code&gt;important&lt;/code&gt; keyword
&lt;/h2&gt;

&lt;p&gt;If you specify that a property is &lt;code&gt;important&lt;/code&gt; in your CSS, you can re-inforce that rule, regardless of the order.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rebeccapurple&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;brown&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--456cOZ7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nu1ng36gxbleolkg9mvt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--456cOZ7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nu1ng36gxbleolkg9mvt.png" alt="brown re-inforced" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Linux `Vimdiff` Command – How to Compare Two Files in the Command Line</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Sun, 18 Jun 2023 10:29:32 +0000</pubDate>
      <link>https://dev.to/hira_zaira/linux-vimdiff-command-how-to-compare-two-files-in-the-command-line-2bi9</link>
      <guid>https://dev.to/hira_zaira/linux-vimdiff-command-how-to-compare-two-files-in-the-command-line-2bi9</guid>
      <description>&lt;p&gt;Software development and maintenance can get complicated sometimes. And you might find yourself comparing code or configuration changes.&lt;/p&gt;

&lt;p&gt;When you compare them manually, you might make a mistake, and it's easy to miss minute changes. Apart from that, finding changes in large files can be exhausting.&lt;/p&gt;

&lt;p&gt;There are many online tools and text editors that help you efficiently compare files. But there is an easier, hassle-free method to compare files using the Linux command line.&lt;/p&gt;

&lt;p&gt;The Linux command line is very powerful and provides a file comparison utility within  &lt;code&gt;vim&lt;/code&gt;  to differentiate files side by side.&lt;/p&gt;

&lt;p&gt;Learning file comparison in the command line is helpful because many servers use only a CLI (Command Line Interface). This means that you don't have the luxury of a GUI where you can run the browser or other text editors.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is vimdiff?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Vimdiff&lt;/code&gt;  is a Linux command that can edit two, three, or four versions of a file with  &lt;code&gt;Vim&lt;/code&gt;  and show their differences.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;Vimdiff&lt;/code&gt;  syntax
&lt;/h3&gt;

&lt;p&gt;For comparing two files, the syntax is the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; vimdiff &lt;span class="o"&gt;[&lt;/span&gt;options] file1 file2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's compare two files  &lt;code&gt;index.js&lt;/code&gt;  and  &lt;code&gt;index.js.bkp&lt;/code&gt;  to see their differences.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vimdiff index.js index.js.bkp 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg2rffiR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zg2rffiR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-13.png" alt="image-13" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we can see the difference in the highlighted line.&lt;/p&gt;

&lt;p&gt;To make things easier, we can show the line number as well. When you are in  &lt;code&gt;Vim&lt;/code&gt;, go to the extended command mode by pressing escape twice and typing  &lt;code&gt;:set number&lt;/code&gt;. This will reveal the line numbers for the current session.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wI7kqGGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wI7kqGGB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-14.png" alt="image-14" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's have a closer look at the output again:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r4Ef2-YL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r4Ef2-YL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-16.png" alt="image-16" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Uncollapsed lines:&lt;/strong&gt; These are the lines of codes that have not been changed. these are wrapped and can be uncollapsed using a combination of the  &lt;code&gt;z+c&lt;/code&gt;  and  &lt;code&gt;z+o&lt;/code&gt;  keys.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Highlighted changes:&lt;/strong&gt; These are the differences present in a file.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Line numbers:&lt;/strong&gt;  These are the corresponding line numbers in files.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;File names:&lt;/strong&gt;  The file name on the left is the first filename mentioned in the command. The file name on the right is the second filename provided in the command.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a way to enable line numbers in Vim by default so you don't have to set it manually each time.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to show line numbers by default in Vim on Linux
&lt;/h3&gt;

&lt;p&gt;If you like to view line numbers by default in  &lt;code&gt;Vim&lt;/code&gt;, you can follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Locate the  &lt;code&gt;vimrc&lt;/code&gt;  file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Vim&lt;/code&gt;  configurations are present in the  &lt;code&gt;vimrc&lt;/code&gt;  file. The file location might vary from one Linux distribution to the other. In Ubuntu, the  &lt;code&gt;vimrc&lt;/code&gt;  file is located in  &lt;code&gt;/usr/share/vim/&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Edit the  &lt;code&gt;vimrc&lt;/code&gt;  file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simply append  &lt;code&gt;set number&lt;/code&gt;  in the file and save and exit.&lt;/p&gt;

&lt;p&gt;Now whenever you open  &lt;code&gt;Vim&lt;/code&gt;, the line numbers will be there by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;Vimdiff&lt;/code&gt;  Operations
&lt;/h2&gt;

&lt;p&gt;Let's see how we can utilize the powers of  &lt;code&gt;vimdiff&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, make sure you are in the command mode.&lt;/p&gt;

&lt;p&gt;You can go into the command mode by pressing the  &lt;code&gt;escape&lt;/code&gt;  key twice.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to split screens horizontally
&lt;/h3&gt;

&lt;p&gt;By default,  &lt;code&gt;vimdiff&lt;/code&gt;  splits the screen vertically. If you like to see the files split horizontally, you can use the flag  &lt;code&gt;-o&lt;/code&gt;  like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vimdiff &lt;span class="nt"&gt;-o&lt;/span&gt; index.js index.js.bkp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--req2Ffi1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--req2Ffi1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-17.png" alt="image-17" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to navigate in diff window
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Navigate between diff windows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To navigate between panes, use a key combination of  &lt;code&gt;Ctrl+W+W&lt;/code&gt;. The cursor will switch between the files once you press the keys.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Jump to changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of scrolling down line by line and scanning for the changes, you can jump to the change with a specific key combination.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; To move to the previous change use:  &lt;code&gt;[ + c&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; To move to the previous change use:  &lt;code&gt;] + c&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How to apply changes from diff window
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  To apply changes from the left file to the right file:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To apply the changes from the left file to the right file, first, move to the highlighted change. Then, use the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:diffput&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Remember that you'll need to be in the command mode.&lt;/p&gt;

&lt;p&gt;Using  &lt;code&gt;diffput&lt;/code&gt;  to apply changes from left to right:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jCo1IP_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jCo1IP_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-18.png" alt="image-18" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  To apply changes from the right file to the left file:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To apply the changes from the right file to the left file, first, move to the highlighted change. Then, use the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:diffget&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using  &lt;code&gt;diffget&lt;/code&gt;  to apply changes from right to left:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z5GHouP5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z5GHouP5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-19.png" alt="image-19" width="800" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to undo changes
&lt;/h3&gt;

&lt;p&gt;If you make a mistake, you can undo the changes provided you didn't save the file.&lt;/p&gt;

&lt;p&gt;When you are in the command mode press  &lt;code&gt;u&lt;/code&gt;  to undo the last change.&lt;/p&gt;

&lt;p&gt;If you've recently undone a change, you won't be able to see the highlighted changes as before. You'll need to refresh to see the changes once again. You can do this by using the command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:diffupdate&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to open and close folds
&lt;/h3&gt;

&lt;p&gt;The unchanged lines are wrapped to provide better readability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BWO0QRTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BWO0QRTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2022/08/image-33.png" alt="image-33" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view the uncollapsed lines as shown above, move the cursor there and use the following key combinations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  To open the folds:  &lt;code&gt;z + o&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  To close the folds:  &lt;code&gt;z + c&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to exit the diff window
&lt;/h3&gt;

&lt;p&gt;There are many ways to exit the diff window depending on the end result.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;:qa&lt;/code&gt;  to exit all the files without saving.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;:q&lt;/code&gt;  to exit the files one by one without saving.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;:wq!&lt;/code&gt;  to save and exit files one by one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Comparing files is easy and fast with  &lt;code&gt;vimdiff&lt;/code&gt;  as we compare files within the command line. In this tutorial, you learned how to use the  &lt;code&gt;vimdiff&lt;/code&gt;  command to efficiently find differences in code or configuration files.&lt;/p&gt;

&lt;p&gt;I hope you found this tutorial helpful. Thank you for reading till the end.&lt;/p&gt;

&lt;p&gt;What’s your favorite thing you learned from this tutorial? Let me know on  &lt;a href="https://twitter.com/hira_zaira"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;I would love to connect with you on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0dYYL6zw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/practicaldev/image/fetch/s--lTK5eo7c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfwvazd9y2xuvmdl1746.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Image credits:&lt;br&gt;&lt;br&gt;
Programming vector created by storyset - &lt;a href="http://www.freepik.com"&gt;www.freepik.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>Vim tutorial- learn Vim the easy way</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Sat, 17 Jun 2023 10:22:14 +0000</pubDate>
      <link>https://dev.to/hira_zaira/vim-tutorial-learn-vim-the-easy-way-l82</link>
      <guid>https://dev.to/hira_zaira/vim-tutorial-learn-vim-the-easy-way-l82</guid>
      <description>&lt;p&gt;Vim is a very powerful and easy to use built-in Linux text editor. In fact, once you master it, vim is the only text editing tool you need to know. Many say it's hard to use, dull and boring but it's all gibberish! I am writing this post to change your views about vim :)&lt;/p&gt;

&lt;p&gt;Vi or vim (vi enhanced) are text editors available in Linux distributions by default. It would be quite unfair to simply not be bestowed with their advantages.&lt;/p&gt;

&lt;p&gt;If you are used to downloading the file, making changes using a GUI, and then uploading the file back to server, then please stop :p You'll stop doing this once you get to know vi. Besides, these steps are unnecessary and Kafkaesque*, right? This also puts the file in danger by adding extra whitespace which might soon turn into an untraceable production nightmare.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Nerd fact - Kafkaesque meaning: something that has been made complex illogically and in a bizarre way.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantaged of using Vim?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vim editor is available by default on all Linux distros. You can start working on it right-away.&lt;/li&gt;
&lt;li&gt;Some other Linux utilities, for example, editing cron jobs, work in the same pattern as vim.&lt;/li&gt;
&lt;li&gt;No internet, no mercy. Let's say you are used to working in other (non-default) editing tools but suddenly if you lose access to those tools, and there is no internet access to install them, then you know where you stand. This could happen if you are trouble shooting in someone else's environment.&lt;/li&gt;
&lt;li&gt;Most servers run headless, so in system administration, you don't necessarily have the luxury of a GUI. But vim has got your back; it would always be there.&lt;/li&gt;
&lt;li&gt;As vim is a CLI tool, it is faster than GUI tools.&lt;/li&gt;
&lt;li&gt;Vim keeps the file properties intact. Downloading the file, editing and uploading it increases the chance of whitespace addition. This could be the case with third party text editing tools as well.&lt;/li&gt;
&lt;li&gt;Vim is suitable for all- beginners and advanced users. Vim supports complex string searches, highlighting searches and much more. Some developers even use vim for code editing, sounds strange right? But you can see the potential here :)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to start using Vim ?
&lt;/h2&gt;

&lt;p&gt;It's easy. You need to know the 3 operating modes of Vim and how to switch between them. Keystrokes behave differently in each command mode, and that's the magic of Vim :D Let's dive deeper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Moving to Start or End of Line in Vim
&lt;/h2&gt;

&lt;p&gt;Press &lt;code&gt;^&lt;/code&gt; to move the cursor to the start of the current line. Press &lt;code&gt;$&lt;/code&gt; to move the cursor to the end of the current line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vim modes
&lt;/h2&gt;

&lt;p&gt;In Vim, there are three modes to work with:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Command mode. &lt;/li&gt;
&lt;li&gt;Edit mode.&lt;/li&gt;
&lt;li&gt;Visual mode.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Command Mode.
&lt;/h3&gt;

&lt;p&gt;When starting vim editor, you land in the command mode by default. This mode allows you to access other modes.&lt;/p&gt;

&lt;p&gt;⚠ &lt;em&gt;To switch to other modes, you need to be present in the command mode first&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Edit Mode
&lt;/h3&gt;

&lt;p&gt;This mode allows you to make changes to the file. To enter edit mode, press 'I' while in command mode.&lt;/p&gt;

&lt;p&gt;Note the  &lt;em&gt;'-- INSERT'&lt;/em&gt;  switch at the end of the screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjXtO-dW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ii10qzkk9cst4okxz1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjXtO-dW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ii10qzkk9cst4okxz1q.png" alt="Insert mode in vim" width="433" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Visual mode
&lt;/h2&gt;

&lt;p&gt;This mode allows you to work on a single character, a block of text, or lines of text.&lt;/p&gt;

&lt;p&gt;Let's break it down into simple steps. Remember, use the below combinations when in command mode.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shift + V → Select multiple lines.&lt;/li&gt;
&lt;li&gt;Ctrl + V → Block mode&lt;/li&gt;
&lt;li&gt;V → Character mode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The visual mode comes into handy when you need to copy and paste or edit lines in bulk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H5MXtdPf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5ukzgmc15fzwyw7qr4x.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H5MXtdPf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5ukzgmc15fzwyw7qr4x.gif" alt="Image description" width="673" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extended command mode.
&lt;/h2&gt;

&lt;p&gt;The extended command mode allows you to perform advanced operations like searching, setting line numbers, and highlighting text. We'll cover extended mode in the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to stay on track?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you forget your current mode, just press ESC twice and you would be back in Command Mode.&lt;/p&gt;

&lt;h3&gt;
  
  
  Some common operations using Vim
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. How to copy and paste in Vim?
&lt;/h4&gt;

&lt;p&gt;Copy-paste is known as  &lt;strong&gt;'yank' and 'put'&lt;/strong&gt; in Linux terms.&lt;/p&gt;

&lt;p&gt;To copy-paste, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Select text in visual mode.&lt;/li&gt;
&lt;li&gt; Press 'y' to copy/ yank.&lt;/li&gt;
&lt;li&gt; Move your cursor to the required position and press 'p'.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  2. How to search for text in Vim?
&lt;/h4&gt;

&lt;p&gt;Any series of strings can be searched with vim using the '/' in command mode.&lt;/p&gt;

&lt;p&gt;To search, use &lt;code&gt;/string-to-match&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In the command mode, type &lt;code&gt;:set hls&lt;/code&gt;. This will highlight the searches.&lt;/p&gt;

&lt;p&gt;Let's search a few strings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nhtBItAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8l94xk48arc083cn43k.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nhtBItAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8l94xk48arc083cn43k.gif" alt="search text in extended command mode" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. How to exit Vim?
&lt;/h4&gt;

&lt;p&gt;That is a million dollar question! 😃&lt;br&gt;
But it is as easy as abc, trust me.&lt;/p&gt;

&lt;p&gt;First, move to command mode(by pressing escape twice) and then use these flags:&lt;/p&gt;

&lt;p&gt;Exit without saving → &lt;code&gt;:q!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Exit and save → &lt;code&gt;:wq!&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using hjkl for navigation
&lt;/h3&gt;

&lt;p&gt;In early days of CLI, the keyboards didn't have arrow keys. Hence, navigation was done using the set of available keys, hjkl being one of them.&lt;/p&gt;

&lt;p&gt;Although arrow keys would work totally fine, you can still experiment with &lt;code&gt;hjkl&lt;/code&gt; keys to navigate. Some people find this this way of navigation comfortable.&lt;/p&gt;

&lt;p&gt;Tip to remember:  &lt;strong&gt;h&lt;/strong&gt;ang back,  &lt;strong&gt;j&lt;/strong&gt;ump down,  &lt;strong&gt;k&lt;/strong&gt;ick up,  &lt;strong&gt;l&lt;/strong&gt;eap forward.&lt;/p&gt;

&lt;h3&gt;
  
  
  Time for action !! 😁
&lt;/h3&gt;

&lt;p&gt;Remember learning in IT is nothing without hands-on. To quickly access a Linux shell and practice what you have learned, hop on to  &lt;a href="https://replit.com/"&gt;Replit&lt;/a&gt;! It's free! This tutorial was made using replit.&lt;/p&gt;

&lt;p&gt;So, this is it ! You have mastered the basics. With this tutorial, you can easily view, edit and save your files using the Vim editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;I would love to connect with you on any of these &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bmc.link/zairah"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lTK5eo7c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfwvazd9y2xuvmdl1746.png" alt="Image description" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>linux</category>
      <category>bash</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Bash Scripting Tutorial – Linux Shell Script and Command Line for Beginners</title>
      <dc:creator>zaira</dc:creator>
      <pubDate>Thu, 15 Jun 2023 17:56:38 +0000</pubDate>
      <link>https://dev.to/hira_zaira/bash-scripting-tutorial-linux-shell-script-and-command-line-for-beginners-1p51</link>
      <guid>https://dev.to/hira_zaira/bash-scripting-tutorial-linux-shell-script-and-command-line-for-beginners-1p51</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pb_Rtp2G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e75b20o7dup50x66tshg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pb_Rtp2G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e75b20o7dup50x66tshg.png" alt="Image description" width="800" height="447"&gt;&lt;/a&gt;In Linux, process automation relies heavily on shell scripting. This involves creating a file containing a series of commands that can be executed together.&lt;/p&gt;

&lt;p&gt;In this article, we'll start with the basics of bash scripting which includes variables, commands, inputs/ outputs, and debugging. We'll also see examples of each along the way.&lt;/p&gt;

&lt;p&gt;Let's get started. 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt;Pre-requisites&lt;br&gt;
Introduction&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Definition of Bash scripting
&lt;/li&gt;
&lt;li&gt;  Advantages of Bash scripting
&lt;/li&gt;
&lt;li&gt;  Overview of Bash shell and command line interface
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How to Get Started with Bash Scripting&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  How to Run Bash Commands from the Command Line
&lt;/li&gt;
&lt;li&gt;  How to Create and Execute Bash Scripts
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bash Scripting Basics&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Comments in bash scripting
&lt;/li&gt;
&lt;li&gt;  Variables and data types in Bash
&lt;/li&gt;
&lt;li&gt;  Input and output in Bash scripts
&lt;/li&gt;
&lt;li&gt;  Basic Bash commands (echo, read, etc.)
&lt;/li&gt;
&lt;li&gt;  Conditional statements (if/else)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Looping and Branching in Bash&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  While loop
&lt;/li&gt;
&lt;li&gt;  For loop
&lt;/li&gt;
&lt;li&gt;  Case statements
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How to Schedule Scripts using cron&lt;br&gt;
&lt;a href="https://dev.toh#how-to-debug-and-troubleshoot-bash-scripts"&gt;How to Debug and Troubleshoot Bash Scripts&lt;/a&gt;&lt;br&gt;
Conclusion&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Resources for learning more about Bash scripting
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;To follow along with this tutorial, you should have the following accesses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  A running version of Linux with access to the command line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you do not have Linux installed or you are just starting out, you can easily access the Linux command line through  &lt;a href="https://replit.com/~"&gt;Replit&lt;/a&gt;. Replit is a browser-based IDE where you can access the bash shell in a few minutes.&lt;/p&gt;

&lt;p&gt;You can also install Linux on top of your Windows system using WSL (Windows Subsystem for Linux).  &lt;a href="https://www.freecodecamp.org/news/how-to-install-wsl2-windows-subsystem-for-linux-2-on-windows-10/"&gt;Here&lt;/a&gt;  is a tutorial for that.&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Definition of Bash scripting
&lt;/h3&gt;

&lt;p&gt;A bash script is a file containing a sequence of commands that are executed by the bash program line by line. It allows you to perform a series of actions, such as navigating to a specific directory, creating a folder, and launching a process using the command line.&lt;/p&gt;

&lt;p&gt;By saving these commands in a script, you can repeat the same sequence of steps multiple times and execute them by running the script.&lt;/p&gt;
&lt;h3&gt;
  
  
  Advantages of Bash scripting
&lt;/h3&gt;

&lt;p&gt;Bash scripting is a powerful and versatile tool for automating system administration tasks, managing system resources, and performing other routine tasks in Unix/Linux systems. Some advantages of shell scripting are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Automation&lt;/strong&gt;: Shell scripts allow you to automate repetitive tasks and processes, saving time and reducing the risk of errors that can occur with manual execution.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Portability&lt;/strong&gt;: Shell scripts can be run on various platforms and operating systems, including Unix, Linux, macOS, and even Windows through the use of emulators or virtual machines.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Flexibility&lt;/strong&gt;: Shell scripts are highly customizable and can be easily modified to suit specific requirements. They can also be combined with other programming languages or utilities to create more powerful scripts.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Accessibility&lt;/strong&gt;: Shell scripts are easy to write and don't require any special tools or software. They can be edited using any text editor, and most operating systems have a built-in shell interpreter.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Integration&lt;/strong&gt;: Shell scripts can be integrated with other tools and applications, such as databases, web servers, and cloud services, allowing for more complex automation and system management tasks.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Debugging&lt;/strong&gt;: Shell scripts are easy to debug, and most shells have built-in debugging and error-reporting tools that can help identify and fix issues quickly.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Overview of Bash shell and command line interface
&lt;/h3&gt;

&lt;p&gt;The terms "shell" and "bash" are used interchangeably. But there is a subtle difference between the two.&lt;/p&gt;

&lt;p&gt;The term "shell" refers to a program that provides a command-line interface for interacting with an operating system. Bash (Bourne-Again SHell) is one of the most commonly used Unix/Linux shells and is the default shell in many Linux distributions.&lt;/p&gt;

&lt;p&gt;A shell or command-line interface looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wvhL932l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-135.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wvhL932l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-135.png" alt="image-135" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The shell accepts commands from the user and displays the output&lt;/p&gt;

&lt;p&gt;In the above output,  &lt;code&gt;zaira@Zaira&lt;/code&gt;  is the shell prompt. When a shell is used interactively, it displays a  &lt;code&gt;$&lt;/code&gt;  when it is waiting for a command from the user.&lt;/p&gt;

&lt;p&gt;If the shell is running as root (a user with administrative rights), the prompt is changed to  &lt;code&gt;#&lt;/code&gt;. The superuser shell prompt looks like this:&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="o"&gt;[&lt;/span&gt;root@host ~]#
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although Bash is a type of shell, there are other shells available as well, such as Korn shell (ksh), C shell (csh), and Z shell (zsh). Each shell has its own syntax and set of features, but they all share the common purpose of providing a command-line interface for interacting with the operating system.&lt;/p&gt;

&lt;p&gt;You can determine your shell type using the  &lt;code&gt;ps&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;ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the output for me:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vEQeMs-Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-134.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vEQeMs-Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-134.png" alt="image-134" width="417" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Checking the shell type. I'm using bash shell&lt;/p&gt;

&lt;p&gt;In summary, while "shell" is a broad term that refers to any program that provides a command-line interface, "Bash" is a specific type of shell that is widely used in Unix/Linux systems.&lt;/p&gt;

&lt;p&gt;Note: In this tutorial, we will be using the "bash" shell.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Get Started with Bash Scripting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Running Bash commands from the command line
&lt;/h3&gt;

&lt;p&gt;As mentioned earlier, the shell prompt looks something like this:&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="o"&gt;[&lt;/span&gt;username@host ~]&lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can enter any command after the  &lt;code&gt;$&lt;/code&gt;  sign and see the output on the terminal.&lt;/p&gt;

&lt;p&gt;Generally, commands follow this syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;command [OPTIONS] arguments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's discuss a few basic bash commands and see their outputs. Make sure to follow along :)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;date&lt;/code&gt;: Displays the current date
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zaira@Zaira:~/shell-tutorial&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;date
&lt;/span&gt;Tue Mar 14 13:08:57 PKT 2023
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;pwd&lt;/code&gt;: Displays the present working directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zaira@Zaira:~/shell-tutorial&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;
/home/zaira/shell-tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;ls&lt;/code&gt;: Lists the contents of the current directory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zaira@Zaira:~/shell-tutorial&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls
&lt;/span&gt;check_plaindrome.sh  count_odd.sh  &lt;span class="nb"&gt;env  &lt;/span&gt;log  temp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;echo&lt;/code&gt;: Prints a string of text, or value of a variable to the terminal.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zaira@Zaira:~/shell-tutorial&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello bash"&lt;/span&gt;
Hello bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can always refer to a commands manual with the  &lt;code&gt;man&lt;/code&gt;  command.&lt;/p&gt;

&lt;p&gt;For example, the manual for  &lt;code&gt;ls&lt;/code&gt;  looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k-jx-Mvr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-138.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k-jx-Mvr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-138.png" alt="image-138" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see options for a command in detail using  &lt;code&gt;man&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Create and Execute Bash scripts
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Script naming conventions
&lt;/h4&gt;

&lt;p&gt;By naming convention, bash scripts end with  &lt;code&gt;.sh&lt;/code&gt;. However, bash scripts can run perfectly fine without the  &lt;code&gt;sh&lt;/code&gt;  extension.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding the Shebang
&lt;/h4&gt;

&lt;p&gt;Bash scripts start with a  &lt;code&gt;shebang&lt;/code&gt;. Shebang is a combination of  &lt;code&gt;bash #&lt;/code&gt;  and  &lt;code&gt;bang !&lt;/code&gt;  followed by the bash shell path. This is the first line of the script. Shebang tells the shell to execute it via bash shell. Shebang is simply an absolute path to the bash interpreter.&lt;/p&gt;

&lt;p&gt;Below is an example of the shebang statement.&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find your bash shell path (which may vary from the above) using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Creating our first bash script
&lt;/h4&gt;

&lt;p&gt;Our first script prompts the user to enter a path. In return, its contents will be listed.&lt;/p&gt;

&lt;p&gt;Create a file named  &lt;code&gt;run_all.sh&lt;/code&gt;  using the  &lt;code&gt;vi&lt;/code&gt;  command. You can use any editor of your choice.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Add the following commands in your file and save it:&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;"Today is "&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;enter the path to directory"&lt;/span&gt;
&lt;span class="nb"&gt;read &lt;/span&gt;the_path

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; you path has the following files and folders: "&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nv"&gt;$the_path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Script to print contents of a user supplied directory&lt;/p&gt;

&lt;p&gt;Let's take a deeper look at the script line by line. I am displaying the same script again, but this time with line numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  1 &lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
  2 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Today is "&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
  3
  4 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;enter the path to directory"&lt;/span&gt;
  5 &lt;span class="nb"&gt;read &lt;/span&gt;the_path
  6
  7 &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; you path has the following files and folders: "&lt;/span&gt;
  8 &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nv"&gt;$the_path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Line #1: The shebang (&lt;code&gt;#!/bin/bash&lt;/code&gt;) points toward the bash shell path.&lt;/li&gt;
&lt;li&gt;  Line #2: The  &lt;code&gt;echo&lt;/code&gt;  command is displaying the current date and time on the terminal. Note that the  &lt;code&gt;date&lt;/code&gt;  is in backticks.&lt;/li&gt;
&lt;li&gt;  Line #4: We want the user to enter a valid path.&lt;/li&gt;
&lt;li&gt;  Line #5: The  &lt;code&gt;read&lt;/code&gt;  command reads the input and stores it in the variable  &lt;code&gt;the_path&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  line #8: The  &lt;code&gt;ls&lt;/code&gt;  command takes the variable with the stored path and displays the current files and folders.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Executing the bash script
&lt;/h4&gt;

&lt;p&gt;To make the script executable, assign execution rights to your user using this 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;u+x run_all.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;chmod&lt;/code&gt;  modifies the ownership of a file for the current user :&lt;code&gt;u&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;+x&lt;/code&gt;  adds the execution rights to the current user. This means that the user who is the owner can now run the script.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;run_all.sh&lt;/code&gt;  is the file we wish to run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can run the script using any of the mentioned methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;sh run_all.sh&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;bash run_all.sh&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;./run_all.sh&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's see it running in action 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--udLKO61I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/run-script-bash-2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--udLKO61I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/run-script-bash-2.gif" alt="run-script-bash-2" width="800" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bash Scripting Basics
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Comments in bash scripting
&lt;/h3&gt;

&lt;p&gt;Comments start with a  &lt;code&gt;#&lt;/code&gt;  in bash scripting. This means that any line that begins with a  &lt;code&gt;#&lt;/code&gt;  is a comment and will be ignored by the interpreter.&lt;/p&gt;

&lt;p&gt;Comments are very helpful in documenting the code, and it is a good practice to add them to help others understand the code.&lt;/p&gt;

&lt;p&gt;These are examples of comments:&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;# This is an example comment&lt;/span&gt;
&lt;span class="c"&gt;# Both of these lines will be ignored by the interpreter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Variables and data types in Bash
&lt;/h3&gt;

&lt;p&gt;Variables let you store data. You can use variables to read, access, and manipulate data throughout your script.&lt;/p&gt;

&lt;p&gt;There are no data types in Bash. In Bash, a variable is capable of storing numeric values, individual characters, or strings of characters.&lt;/p&gt;

&lt;p&gt;In Bash, you can use and set the variable values in the following ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Assign the value directly:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;country&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Pakistan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Assign the value based on the output obtained from a program or command, using command substitution. Note that  &lt;code&gt;$&lt;/code&gt;  is required to access an existing variable's value.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;same_country&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$country&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This assigns the value of  &lt;code&gt;country&lt;/code&gt;to the new variable  &lt;code&gt;same_country&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To access the variable value, append  &lt;code&gt;$&lt;/code&gt;  to the variable name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;zaira@Zaira:~&lt;span class="nv"&gt;$ country&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Pakistan
zaira@Zaira:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$country&lt;/span&gt;
Pakistan
zaira@Zaira:~&lt;span class="nv"&gt;$ new_country&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$country&lt;/span&gt;
zaira@Zaira:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$new_country&lt;/span&gt;
Pakistan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assigning and printing variable values&lt;/p&gt;

&lt;h3&gt;
  
  
  Variable naming conventions
&lt;/h3&gt;

&lt;p&gt;In Bash scripting, the following are the variable naming conventions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Variable names should start with a letter or an underscore (&lt;code&gt;_&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt; Variable names can contain letters, numbers, and underscores (&lt;code&gt;_&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt; Variable names are case-sensitive.&lt;/li&gt;
&lt;li&gt; Variable names should not contain spaces or special characters.&lt;/li&gt;
&lt;li&gt; Use descriptive names that reflect the purpose of the variable.&lt;/li&gt;
&lt;li&gt; Avoid using reserved keywords, such as  &lt;code&gt;if&lt;/code&gt;,  &lt;code&gt;then&lt;/code&gt;,  &lt;code&gt;else&lt;/code&gt;,  &lt;code&gt;fi&lt;/code&gt;, and so on as variable names.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are some examples of valid variable names in Bash:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;name
count
_var
myVar
MY_VAR

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here are some examples of invalid variable names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;2ndvar &lt;span class="o"&gt;(&lt;/span&gt;variable name starts with a number&lt;span class="o"&gt;)&lt;/span&gt;
my var &lt;span class="o"&gt;(&lt;/span&gt;variable name contains a space&lt;span class="o"&gt;)&lt;/span&gt;
my-var &lt;span class="o"&gt;(&lt;/span&gt;variable name contains a hyphen&lt;span class="o"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following these naming conventions helps make Bash scripts more readable and easier to maintain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Input and output in Bash scripts
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Gathering input
&lt;/h4&gt;

&lt;p&gt;In this section, we'll discuss some methods to provide input to our scripts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Reading the user input and storing it in a variable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can read the user input using the  &lt;code&gt;read&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="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Today is "&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;enter the path to directory"&lt;/span&gt;
&lt;span class="nb"&gt;read &lt;/span&gt;the_path

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;your path has the following files and folders: "&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nv"&gt;$the_path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oTD_z5q_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/name-sh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oTD_z5q_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/name-sh.gif" alt="name-sh" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reading from a file&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This code reads each line from a file named  &lt;code&gt;input.txt&lt;/code&gt;  and prints it to the terminal. We'll study while loops later in this article.&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="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;line
&lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$line&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &amp;lt; input.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Command line arguments&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In a bash script or function,  &lt;code&gt;$1&lt;/code&gt;  denotes the initial argument passed,  &lt;code&gt;$2&lt;/code&gt;  denotes the second argument passed, and so forth.&lt;/p&gt;

&lt;p&gt;This script takes a name as a command-line argument and prints a personalized greeting.&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;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;!"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have supplied  &lt;code&gt;Zaira&lt;/code&gt;  as our argument to the script.&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;"Hello, &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code for the script:  &lt;code&gt;greeting.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UYehEW-E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/name-sh-1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UYehEW-E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/name-sh-1.gif" alt="name-sh-1" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Displaying output
&lt;/h4&gt;

&lt;p&gt;Here we'll discuss some methods to receive output from the scripts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Printing to the terminal:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello, World!"&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints the text "Hello, World!" to the terminal.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Writing to a file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This is some text."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; output.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This writes the text "This is some text." to a file named  &lt;code&gt;output.txt&lt;/code&gt;. Note that the  &lt;code&gt;&amp;gt;&lt;/code&gt;operator overwrites a file if it already has some content.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Appending to a file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"More text."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; output.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This appends the text "More text." to the end of the file  &lt;code&gt;output.txt&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Redirecting output:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; files.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lists the files in the current directory and writes the output to a file named  &lt;code&gt;files.txt&lt;/code&gt;. You can redirect output of any command to a file this way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic Bash commands (echo, read, etc.)
&lt;/h3&gt;

&lt;p&gt;Here is a list of some of the most commonly used bash commands:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;cd&lt;/code&gt;: Change the directory to a different location.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;ls&lt;/code&gt;: List the contents of the current directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;mkdir&lt;/code&gt;: Create a new directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;touch&lt;/code&gt;: Create a new file.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;rm&lt;/code&gt;: Remove a file or directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;cp&lt;/code&gt;: Copy a file or directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;mv&lt;/code&gt;: Move or rename a file or directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;echo&lt;/code&gt;: Print text to the terminal.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;cat&lt;/code&gt;: Concatenate and print the contents of a file.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;grep&lt;/code&gt;: Search for a pattern in a file.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;chmod&lt;/code&gt;: Change the permissions of a file or directory.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;sudo&lt;/code&gt;: Run a command with administrative privileges.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;df&lt;/code&gt;: Display the amount of disk space available.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;history&lt;/code&gt;: Show a list of previously executed commands.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;ps&lt;/code&gt;: Display information about running processes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Conditional statements (if/else)
&lt;/h3&gt;

&lt;p&gt;Expressions that produce a boolean result, either true or false, are called conditions. There are several ways to evaluate conditions, including  &lt;code&gt;if&lt;/code&gt;,  &lt;code&gt;if-else&lt;/code&gt;,  &lt;code&gt;if-elif-else&lt;/code&gt;, and nested conditionals.&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;Syntax&lt;/em&gt;&lt;/strong&gt;*:&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="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; condition &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;statement
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; condition &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;statement 
&lt;span class="k"&gt;else
    do &lt;/span&gt;this by default
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Syntax of bash conditional statements&lt;/p&gt;

&lt;p&gt;We can use logical operators such as AND  &lt;code&gt;-a&lt;/code&gt;  and OR  &lt;code&gt;-o&lt;/code&gt;  to make comparisons that have more significance.&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="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$a&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; 60 &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$b&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; 100 &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This statement checks if both conditions are  &lt;code&gt;true&lt;/code&gt;: a is greater than 60 AND b is less than 100.&lt;/p&gt;

&lt;p&gt;Let's see an example of a Bash script that uses  &lt;code&gt;if&lt;/code&gt;,  &lt;code&gt;if-else&lt;/code&gt;, and  &lt;code&gt;if-elif-else&lt;/code&gt;  statements to determine if a user-inputted number is positive, negative, or zero:&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;"Please enter a number: "&lt;/span&gt;
&lt;span class="nb"&gt;read &lt;/span&gt;num

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$num&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; 0 &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;"&lt;/span&gt;&lt;span class="nv"&gt;$num&lt;/span&gt;&lt;span class="s2"&gt; is positive"&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$num&lt;/span&gt; &lt;span class="nt"&gt;-lt&lt;/span&gt; 0 &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;"&lt;/span&gt;&lt;span class="nv"&gt;$num&lt;/span&gt;&lt;span class="s2"&gt; is negative"&lt;/span&gt;
&lt;span class="k"&gt;else
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$num&lt;/span&gt;&lt;span class="s2"&gt; is zero"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Script to determine if a number is positive, negative, or zero&lt;/p&gt;

&lt;p&gt;The script first prompts the user to enter a number. Then, it uses an  &lt;code&gt;if&lt;/code&gt;  statement to check if the number is greater than 0. If it is, the script outputs that the number is positive. If the number is not greater than 0, the script moves on to the next statement, which is an  &lt;code&gt;if-elif&lt;/code&gt;  statement. Here, the script checks if the number is less than 0. If it is, the script outputs that the number is negative. Finally, if the number is neither greater than 0 nor less than 0, the script uses an  &lt;code&gt;else&lt;/code&gt;  statement to output that the number is zero.&lt;/p&gt;

&lt;p&gt;Seeing it in action 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gxSWY544--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/test-odd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gxSWY544--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/test-odd.gif" alt="test-odd" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Looping and Branching in Bash
&lt;/h2&gt;

&lt;h3&gt;
  
  
  While loop
&lt;/h3&gt;

&lt;p&gt;While loops check for a condition and loop until the condition remains  &lt;code&gt;true&lt;/code&gt;. We need to provide a counter statement that increments the counter to control loop execution.&lt;/p&gt;

&lt;p&gt;In the example below,  &lt;code&gt;(( i += 1 ))&lt;/code&gt;  is the counter statement that increments the value of  &lt;code&gt;i&lt;/code&gt;. The loop will run exactly 10 times.&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="nv"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; &lt;span class="nt"&gt;-le&lt;/span&gt; 10 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
   &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="o"&gt;((&lt;/span&gt; i +&lt;span class="o"&gt;=&lt;/span&gt; 1 &lt;span class="o"&gt;))&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While loop that iterates 10 times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R-HGBJMh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-187.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R-HGBJMh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-187.png" alt="image-187" width="630" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  For loop
&lt;/h3&gt;

&lt;p&gt;The  &lt;code&gt;for&lt;/code&gt;  loop, just like the  &lt;code&gt;while&lt;/code&gt;  loop, allows you to execute statements a specific number of times. Each loop differs in its syntax and usage.&lt;/p&gt;

&lt;p&gt;In the example below, the loop will iterate 5 times.&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="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;1..5&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For loop that iterates 5 times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GiAb_77E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-186.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GiAb_77E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.freecodecamp.org/news/content/images/2023/03/image-186.png" alt="image-186" width="580" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Case statements
&lt;/h3&gt;

&lt;p&gt;In Bash, case statements are used to compare a given value against a list of patterns and execute a block of code based on the first pattern that matches. The syntax for a case statement in Bash is as follows:&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="k"&gt;case&lt;/span&gt; expression &lt;span class="k"&gt;in
    &lt;/span&gt;pattern1&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# code to execute if expression matches pattern1&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    pattern2&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# code to execute if expression matches pattern2&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    pattern3&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# code to execute if expression matches pattern3&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# code to execute if none of the above patterns match expression&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Case statements syntax&lt;/p&gt;

&lt;p&gt;Here, "expression" is the value that we want to compare, and "pattern1", "pattern2", "pattern3", and so on are the patterns that we want to compare it against.&lt;/p&gt;

&lt;p&gt;The double semicolon ";;" separates each block of code to execute for each pattern. The asterisk "*" represents the default case, which executes if none of the specified patterns match the expression.&lt;/p&gt;

&lt;p&gt;Let's see an example.&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="nv"&gt;fruit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"apple"&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$fruit&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
    &lt;span class="s2"&gt;"apple"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This is a red fruit."&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="s2"&gt;"banana"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This is a yellow fruit."&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="s2"&gt;"orange"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This is an orange fruit."&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
    &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Unknown fruit."&lt;/span&gt;
        &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example of case statement&lt;/p&gt;

&lt;p&gt;In this example, since the value of "fruit" is "apple", the first pattern matches, and the block of code that echoes "This is a red fruit." is executed. If the value of "fruit" were instead "banana", the second pattern would match and the block of code that echoes "This is a yellow fruit." would execute, and so on. If the value of "fruit" does not match any of the specified patterns, the default case is executed, which echoes "Unknown fruit."&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Schedule Scripts using cron
&lt;/h2&gt;

&lt;p&gt;Cron is a powerful utility for job scheduling that is available in Unix-like operating systems. By configuring cron, you can set up automated jobs to run on a daily, weekly, monthly, or specific time basis. The automation capabilities provided by cron play a crucial role in Linux system administration.&lt;/p&gt;

&lt;p&gt;Below is the syntax to schedule crons:&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;# Cron job example&lt;/span&gt;
&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt; sh /path/to/script.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the  &lt;code&gt;*&lt;/code&gt;s represent minute(s) hour(s) day(s) month(s) weekday(s), respectively.&lt;/p&gt;

&lt;p&gt;Below are some examples of scheduling cron jobs.&lt;/p&gt;

&lt;p&gt;SCHEDULE&lt;/p&gt;

&lt;p&gt;DESCRIPTION&lt;/p&gt;

&lt;p&gt;EXAMPLE&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 0 * * *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run a script at midnight every day&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 0 * * * /path/to/script.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*/5 * * * *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run a script every 5 minutes&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*/5 * * * * /path/to/script.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 6 * * 1-5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run a script at 6 am from Monday to Friday&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 6 * * 1-5 /path/to/script.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 0 1-7 * *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run a script on the first 7 days of every month&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 0 1-7 * * /path/to/script.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 12 1 * *&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run a script on the first day of every month at noon&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 12 1 * * /path/to/script.sh&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using crontab
&lt;/h3&gt;

&lt;p&gt;The  &lt;code&gt;crontab&lt;/code&gt;  utility is used to add and edit the cron jobs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;crontab -l&lt;/code&gt;  lists the already scheduled scripts for a particular user.&lt;/p&gt;

&lt;p&gt;You can add and edit the cron through  &lt;code&gt;crontab -e&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can read more about corn jobs in my  &lt;a href="https://www.freecodecamp.org/news/cron-jobs-in-linux/"&gt;other article here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Debug and Troubleshoot Bash Scripts
&lt;/h2&gt;

&lt;p&gt;Debugging and troubleshooting are essential skills for any Bash scripter. While Bash scripts can be incredibly powerful, they can also be prone to errors and unexpected behavior. In this section, we will discuss some tips and techniques for debugging and troubleshooting Bash scripts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set the  &lt;code&gt;set -x&lt;/code&gt;  option
&lt;/h3&gt;

&lt;p&gt;One of the most useful techniques for debugging Bash scripts is to set the  &lt;code&gt;set -x&lt;/code&gt;  option at the beginning of the script. This option enables debugging mode, which causes Bash to print each command that it executes to the terminal, preceded by a  &lt;code&gt;+&lt;/code&gt;  sign. This can be incredibly helpful in identifying where errors are occurring in your script.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt;

&lt;span class="c"&gt;# Your script goes here&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check the exit code
&lt;/h3&gt;

&lt;p&gt;When Bash encounters an error, it sets an exit code that indicates the nature of the error. You can check the exit code of the most recent command using the  &lt;code&gt;$?&lt;/code&gt;  variable. A value of  &lt;code&gt;0&lt;/code&gt;  indicates success, while any other value indicates an error.&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="c"&gt;# Your script goes here&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; 0 &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 occurred."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use  &lt;code&gt;echo&lt;/code&gt;  statements
&lt;/h3&gt;

&lt;p&gt;Another useful technique for debugging Bash scripts is to insert  &lt;code&gt;echo&lt;/code&gt;  statements throughout your code. This can help you identify where errors are occurring and what values are being passed to variables.&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="c"&gt;# Your script goes here&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Value of variable x is: &lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# More code goes here&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use the  &lt;code&gt;set -e&lt;/code&gt;  option
&lt;/h3&gt;

&lt;p&gt;If you want your script to exit immediately when any command in the script fails, you can use the  &lt;code&gt;set -e&lt;/code&gt;  option. This option will cause Bash to exit with an error if any command in the script fails, making it easier to identify and fix errors in your script.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;

&lt;span class="c"&gt;# Your script goes here&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Troubleshooting crons by verifying logs
&lt;/h3&gt;

&lt;p&gt;We can troubleshoot crons using the log files. Logs are maintained for all the scheduled jobs. You can check and verify in logs if a specific job ran as intended or not.&lt;/p&gt;

&lt;p&gt;For Ubuntu/Debian, you can find  &lt;code&gt;cron&lt;/code&gt;logs at:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/var/log/syslog

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The location varies for other distributions.&lt;/p&gt;

&lt;p&gt;A cron job log file can look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;2022-03-11 00:00:01 Task started
2022-03-11 00:00:02 Running script /path/to/script.sh
2022-03-11 00:00:03 Script completed successfully
2022-03-11 00:05:01 Task started
2022-03-11 00:05:02 Running script /path/to/script.sh
2022-03-11 00:05:03 Error: unable to connect to database
2022-03-11 00:05:03 Script exited with error code 1
2022-03-11 00:10:01 Task started
2022-03-11 00:10:02 Running script /path/to/script.sh
2022-03-11 00:10:03 Script completed successfully

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cron log&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we started with how to access the terminal and then ran some basic bash commands. We also studied what a bash shell is. We briefly looked at branching the code using loops and conditionals. Finally, we discussed automating the scripts using cron followed by some troubleshooting techniques.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources for learning more about Bash scripting
&lt;/h3&gt;

&lt;p&gt;If you want to dig deeper into the world of bash scripting, I would suggest you have a look at this 6-hour course on Linux at freeCodeCamp.&lt;/p&gt;

&lt;p&gt;What’s your favorite thing you learned from this tutorial? You can also connect &lt;a href="https://www.freecodecamp.org/news/p/01e109a1-569f-45d1-b5db-c35259b5da7f/zaira_.bio.link"&gt;&lt;/a&gt; with me on any of these  &lt;a href="https://zaira_.bio.link/"&gt;platforms&lt;/a&gt;. 📧�&lt;/p&gt;

&lt;p&gt;See you in the next tutorial, happy coding 😁&lt;/p&gt;

&lt;p&gt;Banner image credits: Image by  &lt;a href="https://www.freepik.com/free-vector/hand-drawn-flat-design-devops-illustration_25726540.htm#query=programmer%20linux&amp;amp;position=4&amp;amp;from_view=search&amp;amp;track=ais"&gt;Freepik&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
