• Bash add character to String
    04 May

    Bash Add Character to String

    We can also use these methods to add a string to the given string as well. Using $ Operator Use the $ operator to add character to string in Bash. [crayon-66421bd73bdca616407576/] [crayon-66421bd73bdd1040484784/] the${str} is used to expand the value of the str variable and then appends the string o to it, resulting in the string […]

  • Bash split string and get last element
    16 April

    Bash Split String and Get Last Element

    Using read Command Use the read command with parameter expansion to split the string and get the last element in Bash. [crayon-66421bd73c13c973279296/] [crayon-66421bd73c141963261205/] In the above example, the read command is used with the ${myString##*:} parameter expansion to get the last element of the string which is then assigned to the lastElement variable using the […]

  • 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-66421bd73c467827708588/] [crayon-66421bd73c46c434295747/] 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 […]

  • 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 […]