Linux Articles

Page 53 of 134

How to grep multiline search patterns in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 2K+ Views

In Linux, searching for multiline patterns requires special techniques beyond the basic grep command. While grep is designed primarily for single-line pattern matching, we can use various approaches and tools to search across multiple lines effectively. The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It displays lines that contain the pattern we are trying to search, where the pattern is referred to as a regular expression. Basic Grep Syntax grep [options] pattern [files] Common options include − -c : Count of ...

Read More

How to grep string without filenames in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 6K+ Views

The grep command is a powerful tool for searching patterns in files. By default, when searching multiple files, grep displays the filename along with each matching line. However, sometimes you only want to see the matching lines without the filenames cluttering the output. Let's see a simple example where we grep a pattern in multiple files in a directory. Default grep Behavior with Multiple Files grep -i 'lp' Sample* Sample: The sample was printed via the internet. Sample: I believe lp cares about what the device is. Sample1: This was printed via the ...

Read More

How to insert a text at the beginning of a file in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 3K+ Views

In Linux, there are several ways to insert text at the beginning of a file. The most common and efficient method uses the sed command, which stands for stream editor. This command performs various operations like find, replace, insert, and delete on files without opening them in an editor. Using the sed Command The sed command can modify files in-place using the -i flag, making it perfect for inserting text at the beginning of files. Let's explore this with a practical example. Example Setup Consider a directory d1 containing text files. First, let's check the directory ...

Read More

How to install the latest version of Git on CentOS 7.x/6.x?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 935 Views

Installing the latest version of Git on CentOS can be accomplished through multiple approaches. CentOS repositories often contain older versions of Git, so these methods help you install more recent versions with enhanced features and security updates. Approach 1: Using IUS Community Repository The IUS Community Repository provides updated packages for Enterprise Linux distributions. This is the most straightforward method for getting a recent Git version. Commands yum install epel-release yum remove git rpm -U https://centos7.iuscommunity.org/ius-release.rpm yum install git2u git --version Output immukul@192 lib % git --version git version 2.29.2 ...

Read More

How to invert a grep expression on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 12K+ Views

The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display the lines that contain the pattern that we are trying to search. To invert a grep expression means to display all lines that do NOT match the specified pattern, which is accomplished using the -v option. Basic Grep Syntax grep [options] pattern [files] Common Grep Options -c : Lists only a count of the lines that match a pattern -h : Displays ...

Read More

How to iterate over a list of files with spaces in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 550 Views

In order to iterate over a list of files we will need to make use of the find command that Linux provides us with. When dealing with filenames containing spaces, special handling is required to avoid issues with word splitting. Linux find statement is one of the most widely used commands that allows us to walk a file hierarchy. It is used to find specific files or directories and we can append different flags and options to enhance functionality or perform complex operations. Basic Find Command Example Let's start with a simple example of the find statement: ...

Read More

How to know what the 'errno' means in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 1K+ Views

Errno is a global variable in Linux and Unix systems that indicates the type of error that occurred during system calls and library function execution. When a system call or library function encounters an error, it sets the errno variable to a specific integer value that corresponds to the type of error. This mechanism allows developers to identify and handle different types of errors programmatically. The errno variable is defined in the header file and is thread-local in modern implementations. Each error code has both a numeric value and a symbolic constant name written in uppercase letters. ...

Read More

How to limit the number of results returned from grep in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 1K+ Views

The grep command in Linux is a powerful text search utility used to filter and search for specific patterns in files. When working with large files or datasets, you may want to limit the number of results returned to make the output more manageable and focused. The grep command searches for lines containing a specified pattern (regular expression) and displays matching results. By default, it returns all matching lines, but Linux provides several options to limit and control the output. Syntax grep [options] pattern [files] Common Grep Options Option Description ...

Read More

How to list down all the available commands and aliases on Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 11K+ Views

Linux provides a vast collection of commands and aliases that users can utilize in the terminal. These commands serve different purposes and can be executed from anywhere in the command line interface. Understanding how to list available commands and aliases is essential for efficient Linux system administration and usage. There are several approaches to discover all available commands in Linux. You can write custom shell scripts or use built-in shell functions designed for this purpose. The most effective method involves using the compgen command, which is a bash builtin specifically designed to list various shell components. Using the ...

Read More

How to match two strings that are present in one line with grep in Linux?

Mukul Latiyan
Mukul Latiyan
Updated on 17-Mar-2026 1K+ Views

The grep command in Linux is used to filter searches in a file for a particular pattern of characters. It is one of the most used Linux utility commands to display lines that contain the pattern we are searching for. When we need to find lines containing multiple strings, we can combine grep commands or use pattern matching techniques. The pattern we search for is referred to as a regular expression, and grep provides several methods to match multiple strings on the same line. Basic Grep Syntax grep [options] pattern [files] Common Grep Options ...

Read More
Showing 521–530 of 1,338 articles
« Prev 1 51 52 53 54 55 134 Next »
Advertisements