• Bash add comma to end of each line
    16 April

    Add Comma to End of Each Line in Bash

    1. Overview Adding characters like commas to the end of each line in a text file is a common operation in file processing and data manipulation. This task can be especially useful in formatting data files for CSV conversion or similar purposes. 2. Introduction to Problem Statement Imagine we have a text file named input.txt […]

  • Bash round to 2 decimal places
    16 April

    Round to 2 Decimal Places in Bash

    1. Overview In Bash scripting, dealing with numbers and specifically rounding them to a certain number of decimal places is a common task. For example, given a number like 3.14159, the goal is to round it to two decimal places, resulting in 3.14. This article explores various methods to achieve this in Bash, focusing on […]

  • Bash log output to file
    16 April

    Bash Log Output to File

    Using Redirect Operator To log the output of a bash command to a file, use the redirect operator. There are two types of redirect Operator: > (Standard Output Redirect Operator): It redirects the output of a command to a file and overwrites the file’s contents. >> (Standard Output Append Operator): It appends the command’s output […]

  • Bash remove special characters from String
    16 April

    Bash Remove Special Characters from String

    Using Parameter Expansion Use the parameter expansion with regex to remove the special characters from a string in Bash. [crayon-6768e60ca51cb015235101/] [crayon-6768e60ca51ce285144291/] In this example, the parameter expansion removes all special characters from the "Hello World! This is a test string." string. We can observe that our input string contained two special characters, the exclamation marks […]

  • Bash get absolute path from relative path
    16 April

    Bash Get Absolute Path from Relative Path

    When working with shell scripts, it’s common to need to get the absolute path of a file or directory from its relative path. However, before we dive into how to get the absolute path from a relative path, we must learn the difference between the two types of paths. The relative path is relative to […]

  • Remove character from String in bash
    16 April

    Remove Character from String in Bash

    1. Overview In this article, we will explore different ways to remove characters in String in different scenarios such as removing specific characters, removing first character, removing last character, and removing first and last characters. 2. Using Parameter Expansion Bash’s built-in parameter expansion is best suited for performing string manipulation operations. Let’s explore parameter expansion […]

  • Bash remove double quotes from String
    15 April

    Remove Double Quotes from String in Bash

    1. Overview Removing double quotes from strings is a s crucial task in many scenarios, such as parsing JSON data, cleaning up user input, or preparing strings for further processing. In this article, we will see different ways to remove double quotes from String using tr, parameter expansion, awk, sed and grep. 2. Introduction to […]

  • Bash replace character in String
    15 April

    Replace Character in String in Bash

    1. Overview In this article, we will explore different ways to replace characters in String in different scenarios such as replacing the first or all occurrences of a given character, replacing all occurrences of multiple characters, and substituting a complete word. 2. Using Parameter Expansion Bash’s built-in parameter expansion can be used to manipulate String […]

  • NameError name requests is not defined
    15 April

    NameError: Name requests Is Not Defined

    Python has a name error when you try to use a variable or function that is not defined currently. It means that Python has no idea where to locate the requests module or library you are trying to use in your code when you receive the nameError: name 'requests' is not defined error. There are […]