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 66 of 123
Send stdout to Multiple Commands
Sending stdout to multiple commands is a fundamental technique in Unix-like operating systems that allows you to process the output of one command through multiple operations simultaneously. This approach is essential for creating efficient data processing pipelines and automating complex workflows. Standard output (stdout) is the default stream where programs write their output data. When you run a command in the terminal, the results typically appear on your screen through stdout. Understanding how to redirect and duplicate this output enables powerful command-line operations. Methods for Sending stdout to Multiple Commands Using Pipes Pipes (|) redirect the ...
Read MoreThe Use of Swap Space in Modern Linux Systems
Swap space is a designated area on storage devices that the Linux kernel uses to temporarily store data when the system's RAM (Random Access Memory) becomes full. When physical memory is exhausted, the operating system transfers the least-recently-used pages from RAM to swap space, freeing up memory for active processes. This virtual memory mechanism ensures system stability and prevents out-of-memory errors. How Swap Space Works The Linux kernel uses a page replacement algorithm to determine which memory pages should be moved to swap when RAM becomes scarce. When a process needs access to swapped data, the kernel performs ...
Read MoreLocale Environment Variables in Linux
Locale environment variables in Linux control how the operating system displays and handles language-specific information such as dates, numbers, currency, and text encoding. These variables ensure that users can interact with the system using their preferred language and regional conventions. What is a Locale? A locale is a set of parameters that define a user's language, country, currency, and cultural conventions. It specifies how dates, times, numbers, and character sets are formatted. For example, the US locale uses the dollar ($) as currency and mm/dd/yyyy date format, while the UK locale uses the pound (£) and dd/mm/yyyy format. ...
Read MoreWhen to Use xargs in Linux?
When it comes to working with command-line utilities in Linux, there are many tools and utilities available that can make your life easier. One such utility is xargs, a command that allows you to execute commands on a list of files, or arguments, from standard input. Xargs is particularly useful when you want to perform an operation on a large number of files, and you want to do it quickly and efficiently. In this article, we will discuss various scenarios where you may need to use xargs in Linux. We will also look at some examples to illustrate how ...
Read MoreHow to Print Longest Line(s) in a File in Linux?
Finding the longest line(s) in a file is a common task in Linux system administration and text processing. Whether you're analyzing log files, configuration files, or data files, several command-line tools can help you identify lines with maximum character length efficiently. Method 1: Using wc Command The wc (word count) command with the -L option finds the length of the longest line in a file. $ wc -L filename For example, with a file named sample.txt containing: This is first line. This is second line. This is the longest line in the ...
Read MoreHow to Evaluate Arithmetic Expressions in Bash?
Bash is a powerful shell scripting language used on Linux and Unix systems. One of the most common tasks in shell scripting is evaluating arithmetic expressions. This article explores various methods to evaluate mathematical calculations in Bash scripts. Methods for Arithmetic Evaluation Bash provides several ways to evaluate arithmetic expressions. While the traditional expr command exists, modern Bash offers more efficient built-in methods. Using expr Command The expr command evaluates expressions passed as arguments: $ expr 2 + 3 5 Using Arithmetic Expansion $((...)) The preferred method uses double parentheses for ...
Read MoreLinux comm Command
The comm command is a powerful Linux utility used to compare two sorted files line by line. It displays the comparison results in three columns: lines unique to the first file, lines unique to the second file, and lines common to both files. This command is essential for file analysis, data comparison, and finding differences between datasets. Syntax comm [OPTION]... FILE1 FILE2 Where FILE1 and FILE2 are the two sorted files to be compared. Common Options -1 − Suppress column 1 (lines unique to FILE1) -2 − Suppress column 2 (lines unique ...
Read MoreThe Linux join Command
The Linux join command is a powerful text processing utility that merges two sorted files based on a common field. It reads the contents of two files and combines lines that share the same value in a specified field, creating a unified output. This command is particularly useful for database-like operations, combining related data from multiple sources, and creating reports from structured text files. Syntax The basic syntax for the join command is − join [options] file1 file2 Key Options Option Description -t CHAR Specify delimiter ...
Read MoreUsing sed to Replace a Multi-Line String
Sed (Stream Editor) is a powerful command-line tool used for parsing and transforming text in files or streams. While sed operates line-by-line by default, it can be configured to handle multi-line string replacements through special commands and pattern space manipulation. Understanding Sed's Basic Syntax The fundamental structure of sed's substitute command is: s/pattern/replacement/flags Where pattern is a regular expression matching the text to replace, replacement is the new text, and flags modify the command's behavior (such as g for global replacement). Multi-Line String Replacement Technique To replace multi-line strings, sed must load ...
Read MoreLinux Commands – Remove All Text After X
Linux commands provide powerful tools for text manipulation, including the ability to remove all text after a specific character or pattern. This is a common task when processing log files, configuration files, or any text data where you need to truncate content at a certain point. The Sed Command Sed (Stream Editor) is one of the most versatile tools for text manipulation in Linux. To remove all text after a specific character X, use the following syntax: sed 's/X.*/X/' filename This command removes everything after the first occurrence of X while preserving X itself. ...
Read More