• PowerShell remove special characters from String
    14 July

    PowerShell Remove Special Characters from String

    Using Regex.Replace() Method Use the Regex.Replace() method to remove special characters from the specified string in PowerShell. [crayon-6767be007e741764783948/] [crayon-6767be007e748606230293/] First, we declared a variable named $str and set its value to a string containing some special characters. Then, we used the Replace() method of the Regex class from the System.Text.RegularExpressions namespace to replace the special […]

  • PowerShell remove header from Output
    14 July

    PowerShell Remove Header from Output

    For this article, we will use a CSV file, you can use your own, but we will be using inputFile.csv containing the following data: [crayon-6767be007ed41583779049/] Removing Header from Imported Data We can use various ways to remove the header from the imported data before further processing in PowerShell. Let’s learn them below. Use -HideTableHeaders Parameter […]

  • Bash Append to Array
    14 July

    Bash Append to Array

    Using Shorthand Operator Use the Shorthand operator to append one element to an array in Bash. [crayon-6767be007f044192221644/] [crayon-6767be007f049882749517/] First, we declared an array (my_array) with three initial elements element1, element2, and element3. Then, we used the shorthand operator (+=) to append the new_element to the end of an array. Finally, we used the echo command […]

  • Bash get curl response code
    05 July

    Bash Get Curl Response Code

    Using cUrl command with -w, -s and -o options For Get Method Use the -w or --write-out option in combination with the %{http_code} format specifier to get curl response code in Bash for get method. [crayon-6767be007f274781987611/] [crayon-6767be007f279884862017/] We can also rewrite it into more verbose format in case you need for better understanding. [crayon-6767be007f27a256843590/] In […]

  • sed remove line containing string
    03 July

    sed Remove Line Containing String

    Using sed Command Read the provided text file and remove lines containing string using sed command. We will not modify the input file (file.txt) but display the output on the Bash console. We can use -i option in case we want to modify input file [crayon-6767be007f3ca490168020/] [crayon-6767be007f3ce930367163/] [crayon-6767be007f3cf025517931/] Let’s break down command to understand it […]

  • awk remove first column
    03 July

    awk Remove First Column

    Using awk command with sub() method Use the awk command with sub() method to remove the first column from the given CSV file (inputFile.csv) in Bash. We will not update the input file but display the output on the Bash console. [crayon-6767be007f55b563669936/] [crayon-6767be007f55f322048055/] [crayon-6767be007f560292817055/] Here we used $1="" to replace first column with empty string […]

  • Bash remove last line from file
    01 July

    Remove Last Line from File in Bash

    1. Overview In Unix-like environments, especially in scripting and programming with Bash, there might be scenarios where we need to remove the last line from a file. This operation is typical in data processing, log file management, and scripting. 2. Introduction to Problem Statement Imagine we have a text file named test.txt containing the following […]

  • Bash remove spaces from String
    01 July

    Bash Remove Spaces from String

    Using sed Command Use the sed command to remove spaces from string without updating the original variable in Bash. [crayon-6767be007f98d221584466/] [crayon-6767be007f990958553866/] First, we stored the string value in the var variable. Then, we piped it to the sed command, a stream editor performing operations on the text streams. In the above case, we used it […]

  • Bash escape single quotes
    01 July

    Bash Escape Single Quote

    In this tutorial, we will see how to escape single quote in Bash. There are multiple ways to escape single quote in Bash. Let’s go through them. Using Double Quotes Use double quotes to escape single quote in Bash. [crayon-6767be007fc92116775805/] [crayon-6767be007fc96997070366/] Using Backslash Character Use a backslash character (\) to escape a single quote in […]