reworking content
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
All checks were successful
learn org at code.softwareshinobi.com/linux.softwareshinobi.com/pipeline/head This commit looks good
This commit is contained in:
40
landing/docs/Bash-Scripts/006-bash-comments.md
Normal file
40
landing/docs/Bash-Scripts/006-bash-comments.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Comments
|
||||
|
||||
Add comments to your Bash scripts for notes and clarity. Lines starting with `#` are ignored by the interpreter.
|
||||
|
||||
```bash
|
||||
# This is a comment. It will not run.
|
||||
```
|
||||
|
||||
Let's create a new script, `shinobi.sh`, and include comments:
|
||||
|
||||
```bash
|
||||
touch shinobi.sh
|
||||
```
|
||||
|
||||
Now, open `shinobi.sh` and add this:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Ask the user for their name
|
||||
|
||||
read -p "What is your name? " name
|
||||
|
||||
# Greet the user
|
||||
|
||||
echo "Hi there $name"
|
||||
|
||||
echo "Welcome to Dev Team Six!"
|
||||
```
|
||||
|
||||
Save and exit.
|
||||
|
||||
Make your script executable and run it:
|
||||
|
||||
```bash
|
||||
chmod +x shinobi.sh
|
||||
./shinobi.sh
|
||||
```
|
||||
|
||||
Comments are essential. They make your code readable, for yourself and for anyone else who works on it. Clarity drives efficiency.
|
||||
Reference in New Issue
Block a user