Building a Minimal Linux Shell Implementation

Project Overview This project involves creating a minimal shell implementation in Linux that supports basic file and directory operations. The shell should provide an interactive command-line interface and execute common system commands. Core Functionality Requirements Display command prompt with current directory Process user input commands P ...

Posted on Mon, 25 May 2026 18:46:02 +0000 by anothersystem

Bash Test Operators Reference

Logical Operators && - Logical AND || - Logical OR ! - Logical NOT Integer Comparisons Traditional numeric comparison operators: -eq - Equal -ne - Not equal -gt - Greater than -ge - Greater than or equal -lt - Less than -le - Less than or equal Alternative syntax using double parentheses: (("5" < "10")) ((&qu ...

Posted on Mon, 18 May 2026 03:45:47 +0000 by jshowe

5 Methods to Clear File Contents in Linux

Using Standard Redirection The most straightforward way to empty a file is by using the shell redirection operator > without a preceding command. This truncates the file to zero length immediately. > server.log Using the Colon or True Command The : (colon) is a shell built-in command that does nothing and returns a success status ...

Posted on Sun, 17 May 2026 19:53:20 +0000 by TheMoose

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

Essential Linux Command Reference

Vim Process inspection: ps -ef | grep PID Delete text: Ctrl+U: Remove all characters before cursor Ctrl+K: Remove all characters after cursor Batch replacement in Vim: :%s/old/new/g Example: :%s/docker\.io/registry.cn-hangzhou.aliyuncs.com\/acs-sample/g Paste formatted code: :set paste Show line numbers: :set nu Delete all content: :%d ...

Posted on Mon, 11 May 2026 05:08:17 +0000 by Todd88

Batch File Transfer and Command Execution with Shell Scripts

When managing a small number of machines, handling them one by one might be acceptable. However, when dealing with dozens or hundreds of machines, repeating the same commands manually becomes tedious and error-prone. A more efficient approach is to write batch processing shell scripts. This article documents several batch processing scripts, in ...

Posted on Sat, 09 May 2026 18:57:36 +0000 by jimmy patel

Examples of the expr Command in Shell

Overview of expr The expr command is used for integer arithmetic and string operations (like length and pattern matching) in shell scripts. 1. Syntax and Basic Usage Only integer arithmetic is supported. Operators and numbers must be separated by spaces; otherwise, errors occur. The multiplication operator (*) must be escaped. When using expr i ...

Posted on Sat, 09 May 2026 13:26:19 +0000 by danoli3

Understanding Shell Redirection and File Descriptors in Linux

In Linux shells, redirection alters the source or destination of data streams used by commands. Input redirection changes where a program reads its input from, while output redirection changes where it sends its results. By default, standard input comes from the keyboard (file descriptor 0), and standard output and error go to the terminal (des ...

Posted on Fri, 08 May 2026 17:08:06 +0000 by love_php

Advanced Shell Variable Operations

Variable Deletion and Replacement Removing Prefix Patterns Removing the shortest matching prefix pattern using #: greeting="Hello World, Welcome to Shell" echo $greeting greeting_clean=${greeting#*or} echo $greeting_clean Removing the longest matching prefix pattern using ##: greeting_long=${greeting##*or} echo $greeting_long String ...

Posted on Fri, 08 May 2026 14:00:10 +0000 by netpants

Removing Symbolic Links to Directories: The Trailing Slash Trap

In Linux, removing a symbolic link that points to a directory with rm -rf can produce unexpected results depending on whether a trailing / is appended to the path. Careless use of the slash may delete contents of the original directory. Create a test directory and a symlink: $ mkdir -p ~/workspace/project $ echo "some content" > ~/ ...

Posted on Thu, 07 May 2026 07:21:52 +0000 by mahers