Tag: Shell Scripting
Browse all articles, tutorials, and guides about Shell Scripting
Posts
What Does 'set -e' Mean in a Bash Script?
Learn what 'set -e' does in Bash scripts, why it's useful for error handling, and when you might want to use or avoid it. Includes practical examples and caveats.
How to Sleep for Milliseconds in Bash and Linux
Learn how to pause script execution for fractions of a second using sleep, usleep, and other methods for precise timing in Bash scripts and command-line operations.
How to Redirect All Output to a File in Bash
Learn how to redirect stdout and stderr to files in Bash, capture both standard output and errors together, and understand the different redirection operators.
What Does set -e Mean in a Bash Script?
The set -e command in Bash causes your script to exit immediately when any command fails. Learn when to use it, how it works, and common pitfalls to avoid.
How to Prompt for Yes/No/Cancel Input in Linux Shell Scripts
Learn how to create interactive shell scripts that prompt users for confirmation with Yes/No/Cancel options using various techniques and best practices.
Defining Variables with and without Export in Linux Shell
Understand the difference between regular shell variables and exported environment variables, when to use export, and how variable scope affects scripts and processes.
How to Convert Strings to Lowercase in Bash
Discover multiple methods to convert strings to lowercase in Bash scripts, from modern parameter expansion to traditional command-line tools, with examples for different use cases and shell compatibility.
How to Check if a String Contains a Substring in Bash
Learn multiple methods to check for substring presence in Bash, including pattern matching, case-insensitive searches, and practical examples for string validation.
How to Redirect Output to Both a File and stdout in Bash
Discover how to use the tee command and other techniques to send command output to both a file and the terminal simultaneously, useful for logging while monitoring script execution.
How to Get the Current Time in Seconds Since the Epoch in Bash on Linux
Learn how to get Unix timestamps in Bash for logging, benchmarking, and time calculations. Includes examples of converting timestamps, measuring elapsed time, and practical use cases.
How Does cat << EOF Work in Bash?
Understand heredocs in Bash - the << EOF syntax that lets you write multi-line strings, create files with embedded content, and pass complex input to commands.
How to Check for Input Arguments in Bash Shell Scripts
Learn different methods to validate command-line arguments in your Bash scripts, from simple existence checks to handling optional and required parameters with practical examples.
How to Fix Echo Newline in Bash When It Prints Literal \n
Learn why echo sometimes prints literal \n instead of newlines and discover multiple solutions to properly output newline characters in Bash scripts.
How to Prompt for Yes/No/Cancel Input in a Linux Shell Script
Learn different techniques for creating interactive prompts in your shell scripts, from simple yes/no confirmations to three-way choices with proper input validation and user-friendly interfaces.
How to Echo Output to stderr in Bash
Learn different methods to send error messages to stderr in Bash scripts, understand why separating error output from standard output matters, and discover best practices for script logging and debugging.
How to Format Dates as YYYY-MM-DD in Shell Scripts
Learn how to format dates in shell scripts using the date command, including YYYY-MM-DD format and other common date patterns for logging, file naming, and timestamp generation.
How to Check if a File Does Not Exist in Bash
Learn various methods to test for file non-existence in Bash scripts, including proper error handling, permission checks, and practical automation examples.
What Is the Preferred Bash Shebang?
Learn which shebang line to use for Bash scripts, the differences between common options, and how to write portable scripts that work across different Unix-like systems.
How to Check if a Directory Exists in Bash Shell Scripts
Learn multiple methods to check directory existence in Bash scripts, including proper error handling, permission checks, and practical use cases for reliable automation.
How to Get the Directory Where a Bash Script is Located
Learn multiple reliable methods to determine the directory path of your Bash script from within the script itself, including handling symbolic links and edge cases.