Introduction to Shell Scripting

Shell Scripting A shell script is an executable text file that contains shells commands and other specific programming structures. What is a Shell? A shell is a program that acts as a bridge(interface) between you(user) and the operating system(kernel). It takes commands you type, sends them to the operating system kernel, and then shows you the output. Think of it as a command interpreter. Tip: Use this command to check your current shell ...

September 30, 2025 · 5 min · 947 words · Ahmad Hassan

Shell Expansion in Shell Scripting

Shell Expansion In Section we are going to learn about Shell Expansion, How bash perform the Shell Expansion What is Expansion? When you type a command and press Enter, the shell performs several steps before execution. After tokenization, Command Identification (splitting the command into words/tokens) and parsing, the shell performs expansions. Expansion = the process of replacing symbols, variables, or patterns with their actual values. Example: echo $HOME Here $HOME is expanded into your actual home directory path (like /home/ahmad). ...

September 30, 2025 · 12 min · 2391 words · Ahmad Hassan

Shell Operation in Shell Scripting

Shell Operation in Bash The shell (e.g., bash) follows a multi-step process to interpret and execute commands. Each command goes through reading, breaking down, expanding, redirecting, and finally execution. Steps of Command Processing Read Input From terminal (interactive use) or file/script. Reads line by line. Tokenization (Lexical Analysis) Breaks input into words and operators. Follows specific syntax rules. Alias expansion happens at this stage. Parsing / Command Identification Tokens are recognized as: Simple commands (like ls -l) Compound commands (like if, for, pipelines, etc.) Shell Expansions (performed in order): Brace expansion → {a,b,c} → expands to a b c Tilde expansion → ~ → expands to home directory Parameter & variable expansion → $VAR Command substitution → `command` or $(command) Arithmetic expansion → $((2+3)) → 5 Process substitution → <(command) or >(command) Word splitting → breaks expanded words into fields Filename expansion (globbing) → *.txt → matches files Quote Removal Removes " ' and ` while preserving meaning. Redirections Handles input/output redirection, e.g. > >> < 2>&1. Execution The command is executed. If required, the shell waits for the command to finish. Exit status ($?) is collected. Key Points Tokenization is the first transformation stage. Expansions are ordered; each depends on the result of the previous. Redirection happens before execution. Exit status is important for scripting (conditional logic). Shell Tokenization Definition: The process of breaking input into tokens (smallest meaningful units). A token = sequence of characters treated as a single unit by the shell. How Tokenization Works Input Source From terminal or a file (script). Meta Characters Special unquoted characters that separate words. List of meta characters: Space ( ) Tab (\t) Newline (\n) | & ; ( ) < > Types of Tokens Words: tokens without unquoted meta characters. Operators: tokens containing at least one unquoted meta character. Note: If quoted, they lose their special meaning. ...

September 30, 2025 · 12 min · 2363 words · Ahmad Hassan

Variables in Shell Scripting

Variables in Shell Scripting Variables are placeholders to store data (strings, numbers, paths, etc). They don’t require explicit declaration type (untyped). Stored as strings by default in bash/sh. Creating Variables name="Ahmad" age=20 Note: ⚠️ No spaces around =. Using Variables echo $name echo "I am $age years old" $var → expands value(referencing the value of a variable) ${var} → safer form, avoids ambiguity, and useful for appending file="report" echo "${file}_2025.txt" # report_2025.txt Types of Variables User-defined variables (you create) city="Multan" Environment variables (system-wide, inherited by child processes) echo $PATH export MYVAR="hello" Best Practices ...

September 30, 2025 · 8 min · 1595 words · Ahmad Hassan

Setting Up MPD and RMPC

What is RMPC? RMPC is a TUI (terminal UI) client for MPD — it does not do audio output itself, it just sends commands to MPD. (mierak.github.io) So the setup has two parts: Install & configure MPD (the server/daemon that plays music) Install & configure RMPC to connect to MPD Step 1: Install MPD + required clients/tools On Arch-like systems: sudo pacman -S mpd mpc You may also install ncmpcpp (another MPD client) for testing. (ArchWiki) ...

September 27, 2025 · 4 min · 641 words · Ahmad Hassan

Cloud Computing - AWS

Traditional IT Introduction This section is theory-based, no hands-on. Goal: understand the basics of traditional IT infrastructure to see why cloud computing is valuable. How Websites Work Server: A machine hosted somewhere, storing website files and application code. Client (Web Browser): Requests data from the server. Network: Connects the client to the server, routes data packets back and forth. Process: Client sends request over the network. Server processes the request. Server sends back a response. Client displays the website. ...

August 20, 2025 · 7 min · 1322 words · Ahmad Hassan

React – A JavaScript Library

React.js is a JavaScript library for building user interfaces. Developed by Facebook (now Meta) in 2013. It is component-based, declarative, and allows for efficient UI updates. Key Features of React Component-Based Architecture: UI is built using reusable components. Virtual DOM: Updates only the changed parts, making React fast. Unidirectional Data Flow: Props and state maintain a predictable data structure. JSX (JavaScript XML): A syntax extension that lets you write HTML inside JavaScript. Hooks: Allow functional components to have state and other features. Mutable vs Immutable Mutable (Changeable) Mutable data types can be changed after creation. Example: Objects & Arrays are mutable. let arr = [1, 2, 3]; arr.push(4); // Modifies the original array console.log(arr); // [1, 2, 3, 4] Immutable (Unchangeable) Immutable data cannot be changed directly. Instead, you create a new copy. Example: Strings & Numbers are immutable. let str = "Hello"; str[0] = "M"; // This won't change the string console.log(str); // "Hello" Example of immutable object handling (creating a new object instead of modifying the original): ...

June 16, 2025 · 25 min · 5117 words · Ahmad Hassan

The 80/20 Principle

How anyone can be more effective with less effort by learning how to identify and leverage the 80/20 principle–the well-known, unpublicized secret that 80 percent of all our results in business and in life stem from a mere 20 percent of our efforts. The 80/20 principle is one of the great secrets of highly effective people and organizations. Did you know, for example, that 20 percent of customers account for 80 percent of revenues? That 20 percent of our time accounts for 80 percent of the work we accomplish? The 80/20 Principle shows how we can achieve much more with much less effort, time, and resources, simply by identifying and focusing our efforts on the 20 percent t at really counts. Although the 80/20 principle has long influenced today’s business world, author Richard Koch reveals how the principl works and shows how we can use it in a systematic and practical way to vastly increase our effectiveness, and improve our careers and o r companies. ...

May 11, 2025 · 10 min · 1941 words · Ahmad Hassan

Build an AI Chatbot Web App with Google Gemini and Deploy on Vercel

In this article, we’ll walk through the complete process of building an AI chatbot web app powered by Google Gemini and deploying it to the web using Vercel. We’ll use AssistantUI, a modern framework to create conversational experiences using powerful LLMs. Step 1: Install the Prerequisites Before we begin, make sure the following tools are installed on your machine: Install Visual Studio Code (VS Code). Install Node.js (Node.js). Install Git (Git). Step 2: Set Up the Project Directory Create a folder named chatbot: ...

April 19, 2025 · 3 min · 513 words · Ahmad Hassan

MS SQL Server and Azure Data Studio on Arch Linux

Installing MS SQL Server along with Azure Data Studio on Arch Linux requires a combination of Microsoft packages and some extra tweaks since SQL Server isn’t natively available for Arch and Azure Data Studio is mainly targeted for Debian/Red Hat based distros. Step 1: Install Azure Data Studio Azure Data Studio is available via AUR. yay -S azuredatastudio-bin This installs the latest prebuilt version from Microsoft. Option 2: Manual (optional) If you want to manually install: ...

April 15, 2025 · 2 min · 293 words · Ahmad Hassan