A comprehensive collection of Bash scripts demonstrating fundamental to advanced shell scripting concepts. This repository serves as both a learning resource and a practical reference for Linux/Unix shell scripting techniques. It includes both educational scripts covering core concepts and real-world practical projects for system administration tasks.
This repository contains scripts covering:
- Basics: Basic syntax, comments, variables, and constants
- Data Structures: Arrays, key-value pairs, string operations
- Control Flow: If-else statements, case statements, logical operators
- Loops: For, while, until loops with various implementations
- Functions: Creation and usage with arguments
- File Operations: Reading from files, CSV processing
- System Management: Connectivity checks, file existence checks
- Debugging: Logging, error handling techniques
- Advanced Concepts: Background processing, redirection
- Real-world Projects: File archiving, system monitoring, user management
01_basic.sh
- Hello world example02_comments.sh
- Single and multi-line comments03_var.sh
- Variable declaration and usage04_constant_var.sh
- Constants and readonly variables
05_array.sh
- Array operations06_keyvalues.sh
- Key-value pair handling07_string_ops.sh
- String manipulation08_user_int.sh
- User input handling09_arithmetic.sh
- Mathematical operations
10_if_else.sh
- Basic conditionals11_elif.sh
- Multiple condition handling12_choice.sh
- Case statements13_logical.sh
- AND/OR operators14_ternary_ops.sh
- Ternary operations
15_loops.sh
- For loop basics16_for_with_file.sh
- File processing with loops17_for-with_array.sh
- Array iteration18_while_loop.sh
- While loop implementation19_until_loop.sh
- Until loop example20_infinite_loop.sh
- Infinite loop demonstrations21_while_with_file.sh
- File processing with while23_while_with_csv.sh
- CSV processing
24_function.sh
- Function definition and calling25_func_with_args.sh
- Function arguments26-args.sh
- Script arguments27_shift_args.sh
- Shift argument technique
28_break.sh
- Loop breaking29_connectivity_check.sh
- Network connectivity testing30_file_exists_or_not.sh
- File existence verification31_random_dice.sh
- Random number generation32_root_user.sh
- User privilege checking33_redirect.sh
- Output redirection34_dev_null.sh
- Discarding output35_name_retrieve.sh
- Script name retrieval
36_logger.sh
- System logging37_debug.sh
- Script debugging38_debugging.sh
- Error handling with set -e39_running_background.sh
- Background process execution
archieve_files.sh
- Automatically archives large files (20MB+) to save disk spacefile_sys_status.sh
- Monitors filesystem space and sends email alerts when space is lowram_monitoring.sh
- Checks available RAM and provides alerts when memory is running lowuser_make.sh
- Creates new system users with auto-generated passwords and proper permissions
Each script is standalone and can be executed directly after making it executable:
# Make a script executable
chmod +x script_name.sh
# Execute a script
./script_name.sh
This repository is organized in a progressive learning path:
- Start with basics (01-09)
- Move to control structures (10-14)
- Learn loops (15-23)
- Understand functions and arguments (24-27)
- Explore system operations (28-35)
- Master advanced techniques (36-39)
- Apply knowledge with real-world projects
- Bash shell (version 4.0 or higher recommended)
- Linux/Unix environment or Windows with WSL
- Root/sudo access (for some system administration scripts)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Rohan
- GitHub: Ruhon Deb
This repository is maintained and updated regularly. Last update: May 2025