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
Shell Script Functions: Definition, Usage, and Advanced Patterns
Shell Functions
Defining Functions
Functions in shell scripts encapsulate reusable blocks of code. There are two common syntax styles:
# Style 1: Using the function keyword
function my_function {
commands
}
# Style 2: Bash-compatible parentheses syntax
my_function() {
commands
}
Inspecting Defined Functions
The declare builtin provide ...
Posted on Wed, 03 Jun 2026 16:55:32 +0000 by cesy
Understanding Shell Session Types: Interactive vs. Login Modes
The Shell acts as the interface between the Linux kernel and the user, serving as the primary mechanism for system management and communication. Depending on the initialization method, a Shell session operates in one of four distinct modes, defined by two criteria: authentication status (Login or Non-login) and interactivity (Interactive or Non ...
Posted on Mon, 01 Jun 2026 17:49:41 +0000 by spasm37
Automated MySQL Backup Strategy Using Shell Scripting and Remote Synchronization
Data integrity is a critical component of server administration. Relying on manual intervention often leads to inconsistent recovery points. To mitigate this risk, an automated solution utilizing a Bash script provides a reliable mechanism for performing consistent dumps, compressing the output, and securely replicating archives to a remote ser ...
Posted on Sat, 16 May 2026 22:41:12 +0000 by treilad