Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Open Source Articles
Page 51 of 123
How to get the start time of a long running Linux Process?
Whenever we want to get an update about a specific process or different processes, we make use of the ps command which is short for "Process Status". This command tells us about the state of current processes, their characteristics, and much more. When combined with several flags and options, we can enhance the ps command to output the start time of different processes running on a Linux machine. This is particularly useful for monitoring long-running processes and system diagnostics. Basic Commands to Display Process Start Time The command to print the start time of processes varies slightly ...
Read MoreHow to grep a string in a directory and all its subdirectories in Linux?
The grep command in Linux is used to search for specific patterns or strings within files. It is one of the most essential Linux utilities for filtering and finding text content across files and directories. The pattern we search for is typically called a regular expression, and grep can search through single files, multiple files, or entire directory structures. Basic Syntax grep [options] pattern [files] Common Options Option Description -r or -R Search recursively through directories and subdirectories -n Display line numbers with matched ...
Read MoreHow to grep and replace a word in a file on Linux?
While there are plenty of ways to print and make use of specific words from a particular file in a Linux directory, when we talk about grepping a particular word and then replacing it with some other word, we need to use specific Linux utility commands. The two Linux utility commands that we must be aware of are − find − used to locate a particular file or directory sed − short for stream editor and is used to perform functions like searching, editing and replacing Basic Grep and Replace Operation To solve the ...
Read MoreHow to grep multiline search patterns in Linux?
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 MoreHow to grep string without filenames in Linux?
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 MoreHow to insert a text at the beginning of a file in Linux?
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 MoreHow to install the latest version of Git on CentOS 7.x/6.x?
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 MoreHow to invert a grep expression on Linux?
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 MoreHow to iterate over a list of files with spaces in Linux?
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 MoreHow to know what the 'errno' means in Linux?
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