Mastering the sed Stream Editor for System Administration
Overview and Mechanics
The sed (stream editor) is a powerful utility designed for parsing and transforming text streams. Unlike interactive editors, it operates automatically based on scripts or command-line arguments. Internally, sed processes input line by line. Each line is copied into a temporary area known as the Pattern Space. The command ...
Posted on Thu, 23 Jul 2026 16:33:35 +0000 by kokomo310
Extract Nginx Logs by Date Range Using sed
When nginx access logs reach gigabyte scale, utilities like cat or tail become impractical for pinpointing traffic on a specific date. The sed stream editor processes text line-by-line using regular expressions, making it efficient for slicing large log files by timestamp ranges.
Log Timestamp Structure
A standard nginx access entry places the ...
Posted on Tue, 21 Jul 2026 17:08:10 +0000 by SUNNY ARSLAN
Understanding sed Address Patterns and Command Options
The stream editor processes input sequentially, applying transformation rules within a temporary pattern space before flushing results to standard output. Unlike interactive editors, it operates without loading entire files into memory, making it highly efficient for largee datasets and pipeline operations.
Core Command Flags
Configuration flag ...
Posted on Fri, 03 Jul 2026 16:51:26 +0000 by drew69
Advanced sed Techniques for Text File Processing
sed Command Reference
Displaying Specific Lines
To print the 10th line of /etc/passwd:
sed -n '10p' /etc/passwd
To print lines 8 through 15 of /etc/passwd:
sed -n '8,15p' /etc/passwd
To print line 8 and the next 5 lines of /etc/passwd:
sed -n '8,+5p' /etc/passwd
Pattern Matching
To print lines starting with 'nginx' in /etc/passwd:
sed ...
Posted on Mon, 29 Jun 2026 16:09:36 +0000 by mescal
Essential sed Commands for Text Processing
# Print the last line of a file
sed -n '$p' ok.txt
# Output total number of lines
sed -n '$=' ok.txt
# Count blank lines
sed -n '/^$/=' ok.txt
Line Selection and Printing
# Print odd-numbered lines (1st, 3rd, 5th, ...)
seq 10 | sed -n '1~2p'
# Print even-numbered lines (2nd, 4th, 6th, ...)
seq 10 | sed -n '2~2p'
Inserting Content
sed '5 a ...
Posted on Fri, 15 May 2026 06:49:01 +0000 by ghostrider1
Mastering the Stream Editor: A Comprehensive Guide to sed Command Operations
Understanding the Stream Editor (sed)
The Stream Editor (sed) is a powerful utility in Unix/Linux systems for processing text files. It allows you to perform complex text manipulation operations using simple commands. This guide explores the fundamental operations of sed including deletion, insertion, and modification.
Basic Setup
Before workin ...
Posted on Thu, 14 May 2026 13:32:46 +0000 by stefan63
Modifying Network Configuration and Text Processing in Linux
Modifying Network Interface Configuraton
1. Update the Network Configuration File
Edit the configuraton file for the target interface (e.g., ens33).
vim /etc/sysconfig/network-scripts/ifcfg-ens33
Adjust the following parameters:
NAME=enp0 # Corresponds to net.ifnames=0
DEVICE=enp0 # Corresponds to biosdevname=0
2. Rename the Configuratio ...
Posted on Mon, 11 May 2026 09:45:57 +0000 by yogadt