• Bash remove blank lines from file
    29 June

    Bash Remove Blank Lines from File

    We can use any of the below commands if we are required to write the output to a new file. But, we can only use sed and perl commands if instructed to remove blank lines and lines containing whitespace characters and store the updated content in the original file. Using grep Command Use the grep […]

  • Create folder if not exists in Bash
    03 May

    Bash Create Folder if Not Exists

    To run the following commands, directly write the command in the bash terminal and execute them. Using mkdir -p Command Use the mkdir -p command to create folder if not exists in Bash [crayon-66418f0f07d10133103782/] The mkdir is used to create the directory. The -p created all the intermediate directories if they didn’t exist. The /path/to/directory […]

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