sysinfo.sh is a Bash script that displays basic system information such as the current date and time, username, working directory, home directory, and the number of files in the current directory.
This project was built as a learning exercise to understand shell scripting fundamentals, command substitution, environment variables, pipes, and permissions.
The goal of this script is to:
- Practice writing executable shell scripts
- Learn how to retrieve system information from the terminal
- Understand how commands can be combined using pipes
- Explore how Bash performs command substitution similar to JavaScript template literals
The script gathers system information at runtime and formats it into a clean, readable output.
- A Unix-based system (Linux or macOS)
- Bash shell
No external dependencies are required.
git clone https://github.com/AJ1732/shell-script-dashboard.git
cd shell-script-dashboardchmod +x scripts/sysinfo.shThis step is required because scripts are not executable by default.
./scripts/sysinfo.sh==== System Information ====
Date & Time: Fri Jan 23 00:17:42 WAT 2026
Username: mac
Current Directory: /Users/mac/Documents/coding/rise-academy/tasks/week-1
Home Directory: /Users/mac
Files in Current Directory: 4
============================
The script uses command substitution ($(...)) and environment variables to retrieve system information:
$(date)→ current date and time$(whoami)→ current system user$(pwd)→ current working directory$HOME→ user’s home directoryls -A | wc -l→ counts files in the current directory
All values are combined into a multi-line string and printed using echo.
Challenge:
Confusion about how expressions like $(date) work and why they resemble JavaScript template literals.
Solution:
Learned that $(...) runs a command and substitutes its output before execution, similar in concept to ${} in JavaScript.
Challenge:
Expected a command like pwd to exist for the home directory.
Solution:
Learned that the home directory is stored in the environment variable $HOME, which is the idiomatic and correct approach.
Challenge: How to count files.
Solution:
ls | wc -l- Bash scripting basics
- Command substitution
- Environment variables
- Pipes (
|) and command chaining - File permissions
- Writing readable CLI output