When working with text files, you’ll often need to find and replace strings of text in one or more files. The sed is a stream editor. It is used to search, find and replace, insert and delete words and lines. You also can use the regular expressions. In this article we will show you...
The head command is used to print the few first lines (by default 10 lines) of file or standard output. This tutorial shows you how to use the Linux head command with practical examples. Head Command Syntax# Below is the basic syntax for the head command: head [OPTION]... [FILE]... Here, Use of Head Command#...
It’s a basic requirement to rename the files and directories on a Linux system. There are two ways to rename files using command-line terminal or via GUI file manager. In this tutorial, we will cover how to rename files and directories using mv and rename commands. Rename Files using mv Command# The mv command...
Time command is useful when you want to determine the command execution time. Generally, it’s useful to test the performance of the commands and scripts. In this guide, we will cover how to use the time command in Linux. When you are writing multiple script which doing same job and want to choose better...
Sometimes when you are redirecting the output of a command by piping to another command or to a file, you get the error messages. There are three standard I/O streams, which are used in Bash and other Linux shells when a program is executed. Below are the streams and each representing by the numberic...
The printf command have more control over the formatting of the output. It formats and prints arguments similar to the C printf() function. In this article we will see how to use printf command bash. printf Command# Bash and other shells like Zsh and Ksh have printf by default. The standalone binary /usr/bin/printf is...
Using the select construct you can generate menus. In this guide, we will discuss about the basics of the select construct in Bash. Bash select Construct# You can generate a menu from the list of items using the select construct. Following is the syntax for the select construct and it is similar to the...
It’s a best practice to make bash script in a clean and understandable way. You can make you code clean and arrange by indenting, blocks and giving related names of variables and functions. You can also improve the code readability using comments. Comments are human-readable explanation or short description. In this article we will...
Variable increment and decrement is fundamental arithmetic operation in bash scripting. It’s mostly used with the for, while and until loops. Increment means adding value to variable and Decrement means subtracting from numeric variable value. This article explains multiple ways to increment or decrement a variable. Use of + and - Operators# You must...
While you working with string in Bash need to check whether a string contains another string. In this guide, we will show you multiple ways to check if a string contains a substring in bash scripting. Use Wildcards# It is easy to use asterisk wildcard symbols (asterisk) * to compare with the string. Wildcard...