tr Command in Bash Linux

The tr command stands for the translate characters command. It is used for replacing and deleting characters. The tr command operates on standard input and the results are provided to the standard output. There are several options available in the tr command, we will look at some of them with examples in this section. tr command to convert uppercase to lowercase One of the most common uses of the tr command is converting characters from upper to lowercase and vice versa....

April 21, 2022 · 4 min

Bash if Else Elif

Introduction A simple bash may only perform some sequential operations to provide the desired outcome. However, many times, we need scripts that perform some kind of logic control flow. For example, executing a certain command only when a specific condition is met. In this section, we will look into some of the conditional statements that bash provides us to perform such operations with examples. Bash if statement Let us first look at the basic if command in bash scripting....

April 17, 2022 · 8 min

22 Useful Ruby String Methods every ruby programmer should know

Ruby programming language comes with a lot of handy string methods. In this section, we will look at some of them with examples. 1. gsub The gsub method in ruby is used for string replacement. It replaces all the matching patterns with another string. > str = "My favourite character is Mickey. I just love the way Mickey sings." => "My favourite character is Mickey. I just love the way Mickey sings....

April 15, 2022 · 4 min

Using include <iostream> in C++

What is include <iostream> in C++? If you are new to the C++ programming language, you may have noticed the very first line of C++ code contains the code include<iostream>. In this section, we will look at what the statement include<iostream> does and why we should use it. iostream iostream - stands for input/output stream. iostream is a header file that contains a set of functions for standard input and standard output....

April 15, 2022 · 2 min

Test Command in Linux

What is test command in Linux? The test command is used to test a given expression that returns an exit status True or False. There are two ways of declaring the test command, first one is using the keyword test and the second is using the square brackets []. test expression [ expression ] The expression gets evaluated as either true or false. If the test command returns an exit status as 0 then the expression is true....

April 14, 2022 · 9 min

Wildcards in Linux with examples

Introduction The Linux shell comes with a very handy feature called the wildcards which uses special characters to match patterns of characters. This allows us to search and list filenames easily. In this section, we will look into some of the special characters used as wildcards and also learn how they can help us save time with examples. ‘*’ wildcard The asterisk(*) matches zero or more characters. For example, ca* can match...

April 12, 2022 · 2 min

Navigating Linux File System and file management

Introduction Once you install a new operating system, the first thing to you want to do is navigate the file system. In this section we will look at how to navigate through the linux file system using the command prompt and also look at some useful commands to make our life easier. Understanding Linux file structure Before getting into the navigation, it is important to understand the file structure of linux operating system....

April 7, 2022 · 8 min

Command Substitution in Shell Script

Shell scripting offers a very helpful feature for the programmers called the Command substitution feature. Command substitution helps us store the output of a command in a variable. There are two ways of calling the command substitution: Using backtick (`) $ current_directory=`pwd` $ echo $current_directory /home/john $(command) format $ current_directory=$(pwd) $ echo $current_directory /home/john In the above commands, we are assigning the output of the pwd command to the variable current_directory....

April 6, 2022 · 1 min

Linux Shell Variables

Variables are containers used for storing data. They are named memory locations from where we can store and retrieve the values. Assigning variables in Shell script To assign a value to the variable we make use of = symbol as follows: name=Donald The above statement declares a variable name name and assigns it a string Donald. No spaces while assigning variables It is important to note the symbol = does not contain space before or after it....

April 5, 2022 · 5 min

Perl Subroutines

What is a subroutine in Perl? When you want to run a block of code which needs to be executed more than once, it makes sense to be able to group them such that it can be called any number of times to perform the same operation on different variables. In perl, you can do so by organizing them in functions or subroutines. This feature helps us by maintaining a clean, readable and well structured code that can be reused for related tasks....

April 3, 2022 · 3 min