System Health Checker
Part of the Fundamentals section of Coddy's Terminal journey. Lesson 82 of 82.
Challenge
EasyCreate a shell script called health.sh that displays a system health report with the following sections:
- Start with the shebang line (
#!/bin/bash) - Print
=== System Health Report === - Print
User:followed by the output ofid -u - Print
Current Directory:followed by the output ofpwd - Print
Running Processes:followed by the count of lines inprocesses.txt(simulating process count) - Print
=== End of Report ===
Use command substitution $(command) to capture command output within your echo statements.
Make the script executable and run it. The labels must match exactly, while the user id, the directory and the process count come from the machine you are running on, so your numbers can differ:
=== System Health Report ===
User: 1002
Current Directory: /tmp/user/home
Running Processes: 9
=== End of Report ===Try it yourself
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data PipelinePractice on your own: Terminal playground