Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo #150

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you are adding a new translation, make sure to make a copy of the `./ebook/en

All the Markdown files for the 'Introduction to Bash Scripting' guide are located within the [`content`](./content) directory for the specific language.

For example if you are adding a Bulgarian transaltion copy the `./ebook/en` folder to `./ebook/bg`, translate the `.md` files in the `content` directory and submit a PR.
For example if you are adding a Bulgarian translation copy the `./ebook/en` folder to `./ebook/bg`, translate the `.md` files in the `content` directory and submit a PR.

### PDF Generation

Expand All @@ -37,7 +37,7 @@ Make sure to follow the steps on how to get Ibis installed and how to use it her

## Issue Creation

In the event that you have a issue using the guide or have a suggest for a change but don't want to contribute changes,
In the event that you have an issue using the guide or have a suggestion for a change but don't want to contribute changes,
we are more than happy to help.
Make sure that when you create your issue, it follows the format for the type of issue you select
(it has individual templates for each issue type).
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ I think it's essential always to keep professional and surround yourself with go

For more information, please visit my blog at [https://bobbyiliev.com](https://bobbyiliev.com), follow me on Twitter [@bobbyiliev_](https://twitter.com/bobbyiliev_) and [YouTube](https://www.youtube.com/channel/UCQWmdHTeAO0UvaNqve9udRw).

In case that you want to support me you can By Me a Coffee here:
In case that you want to support me you can Buy Me a Coffee here:

<a href="https://www.buymeacoffee.com/bobbyiliev" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

Expand Down Expand Up @@ -167,5 +167,3 @@ If you ever need to create a graphic, poster, invitation, logo, presentation –
## 🤲 Contributing

If you are contributing 🍿 please read the [contributing file](CONTRIBUTING.md) before submitting your pull requests.


6 changes: 2 additions & 4 deletions ebook/en/content/004-bash-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ You can also add variables in the Command Line outside the Bash script and they
```bash
./devdojo.sh Bobby buddy!
```
This script takes in two parameters `Bobby`and `buddy!` seperated by space. In the `devdojo.sh` file we have the following:
This script takes in two parameters `Bobby`and `buddy!` separated by space. In the `devdojo.sh` file we have the following:

```bash
#!/bin/bash
Expand All @@ -117,7 +117,7 @@ echo "Hello there" $@

# $@ : all
```
The ouput for:
The output for:

```bash
./devdojo.sh Bobby buddy!
Expand All @@ -129,5 +129,3 @@ Hello there Bobby
Hello there buddy!
Hello there Bobby buddy!
```


2 changes: 1 addition & 1 deletion ebook/en/content/008-bash-arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If you have ever done any programming, you are probably already familiar with ar

But just in case you are not a developer, the main thing that you need to know is that unlike variables, arrays can hold several values under one name.

You can initialize an array by assigning values devided by space and enclosed in `()`. Example:
You can initialize an array by assigning values divided by space and enclosed in `()`. Example:

```bash
my_array=("value 1" "value 2" "value 3" "value 4")
Expand Down
4 changes: 2 additions & 2 deletions ebook/en/content/009-bash-conditional-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ As with other programming languages you can use `AND` & `OR` conditions:

## Exit status operators

* returns true if the the command was successful without any errors
* returns true if the command was successful without any errors

```bash
[[ $? -eq 0 ]]
```

* returns true if the the command was not successful or had errors
* returns true if the command was not successful or had errors

```bash
[[ $? -gt 0 ]]
Expand Down
4 changes: 2 additions & 2 deletions ebook/en/content/010-bash-conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fi

If you put this on top of your script it would exit in case that the EUID is 0 and would not execute the rest of the script. This was discussed on [the DigitalOcean community forum](https://www.digitalocean.com/community/questions/how-to-check-if-running-as-root-in-a-bash-script).

You can also test multiple conditions with an `if` statement. In this example we want to make sure that the user is neither the admin user or the root user to ensure the script is incapable of causing too much damage. We'll use the `or` operator in this example, noted by `||`. This means that either of the conditions needs to be true. If we used the `and` operator of `&&` then both conditions would need to be true.
You can also test multiple conditions with an `if` statement. In this example we want to make sure that the user is neither the admin user nor the root user to ensure the script is incapable of causing too much damage. We'll use the `or` operator in this example, noted by `||`. This means that either of the conditions needs to be true. If we used the `and` operator of `&&` then both conditions would need to be true.

```bash
#!/bin/bash
Expand All @@ -96,7 +96,7 @@ else
fi
```

If you have multiple conditions and scenerios, then can use `elif` statement with `if` and `else` statements.
If you have multiple conditions and scenarios, then can use `elif` statement with `if` and `else` statements.

```bash
#!/bin/bash
Expand Down
4 changes: 2 additions & 2 deletions ebook/en/content/014-creating-custom-bash-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

As a developer or system administrator, you might have to spend a lot of time in your terminal. I always try to look for ways to optimize any repetitive tasks.

One way to do that is to either write short bash scripts or create custom commands also known as aliases. For example, rather than typing a really long command every time you could just create a short cut for it.
One way to do that is to either write short bash scripts or create custom commands also known as aliases. For example, rather than typing a really long command every time you could just create a shortcut for it.

## Example

Expand All @@ -23,7 +23,7 @@ To avoid that, we can create an alias, so rather than typing the whole command,
alias conn="netstat -plant | grep '80\|443' | grep -v LISTEN | wc -l"
```

That way we are creating an alias called `conn` which would essentially be a 'short cut' for our long `netstat` command. Now if you run just `conn`:
That way we are creating an alias called `conn` which would essentially be a 'shortcut' for our long `netstat` command. Now if you run just `conn`:

```bash
conn
Expand Down
4 changes: 2 additions & 2 deletions ebook/en/content/016-creating-an-interactive-menu-in-bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ $(ColorBlue 'Choose an option:') "

### A quick rundown of the code

First we just echo out the menu optsions with some color:
First we just echo out the menu options with some color:

```
echo -ne "
Expand Down Expand Up @@ -302,4 +302,4 @@ You will be able to choose a different option from the list and each number will

You now know how to create a Bash menu and implement it in your scripts so that users could select different values!

>{notice} This content was initially posted on [DevDojo.com](https://devdojo.com/bobbyiliev/how-to-work-with-json-in-bash-using-jq)
>{notice} This content was initially posted on [DevDojo.com](https://devdojo.com/bobbyiliev/how-to-work-with-json-in-bash-using-jq)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Any command that you can run from the command line can be used in a bash script.

Let's have a hypothetical scenario where you need to execute a BASH script on multiple remote servers, but you don't want to manually copy the script to each server, then again login to each server individually and only then execute the script.

Of course you could use a tool like Ansible but lets learn how to do that with Bash!
Of course you could use a tool like Ansible but let's learn how to do that with Bash!

## Prerequisites

Expand Down
8 changes: 4 additions & 4 deletions ebook/en/content/018-working-with-json-in-bash-using-jq.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Work with JSON in BASH using jq

The `jq` command-line tool is is a lightweight and flexible command-line **JSON** processor. It is great for parsing JSON output in BASH.
The `jq` command-line tool is a lightweight and flexible command-line **JSON** processor. It is great for parsing JSON output in BASH.

One of the great things about `jq` is that it is written in portable C, and it has zero runtime dependencies. All you need to do is to download a single binary or use a package manager like apt and install it with a single command.

## Planning the script

For the demo in this tutorial, I would use an external REST API that returns a simple JSON ouput called the [QuizAPI](https://quizapi.io/):
For the demo in this tutorial, I would use an external REST API that returns a simple JSON output called the [QuizAPI](https://quizapi.io/):

> [https://quizapi.io/](https://quizapi.io/)

Expand Down Expand Up @@ -92,7 +92,7 @@ After running the curl command, the output which you would get would look like t

![Raw Json output](https://imgur.com/KghOfzj.png)

This could be quite hard to read, but thanks to the jq command-line tool, all we need to do is pipe the curl command to jq and we would see a nice formated JSON output:
This could be quite hard to read, but thanks to the jq command-line tool, all we need to do is pipe the curl command to jq and we would see a nice formatted JSON output:

```bash
curl "https://quizapi.io/api/v1/questions?apiKey=${API_KEY}&limit=10" | jq
Expand Down Expand Up @@ -222,4 +222,4 @@ And for more information on the **QuizAPI**, you could take a look at the offici

* [https://quizapi.io/docs/1.0/overview](https://quizapi.io/docs/1.0/overview)

>{notice} This content was initially posted on [DevDojo.com](https://devdojo.com/bobbyiliev/how-to-work-with-json-in-bash-using-jq)
>{notice} This content was initially posted on [DevDojo.com](https://devdojo.com/bobbyiliev/how-to-work-with-json-in-bash-using-jq)
6 changes: 3 additions & 3 deletions ebook/en/content/021-how-to-send-emails-with-bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ sudo apt install mailutils

Now that you have `ssmtp` installed, in order to configure it to use your SMTP server when sending emails, you need to edit the SSMTP configuration file.

Using your favourite text editor opent the `/etc/ssmtp/ssmtp.conf` file:
Using your favourite text editor to open the `/etc/ssmtp/ssmtp.conf` file:

```bash
sudo nano /etc/ssmtp/ssmtp.conf
```

You need to incldue the your SMTP configuration:
You need to include your SMTP configuration:

```
root=postmaster
Expand Down Expand Up @@ -92,4 +92,4 @@ SSMTP is a great and reliable way to implement SMTP email functionality directly

For more information about SSMTP I would recommend checking the official documentation [here](https://wiki.archlinux.org/index.php/SSMTP).

>{notice} This content was initially posted on the [DigitalOcean community forum](https://www.digitalocean.com/community/questions/how-to-send-emails-from-a-bash-script-using-ssmtp).
>{notice} This content was initially posted on the [DigitalOcean community forum](https://www.digitalocean.com/community/questions/how-to-send-emails-from-a-bash-script-using-ssmtp).
6 changes: 3 additions & 3 deletions ebook/en/content/022-bash-password-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Generate the passwords and then print it so the user can use it.
# This is where the magic happens!
# Generate a list of 10 strings and cut it to the desired value provided from the user

for i in {1..10}; do (tr -cd '[:alnum:]' < /dev/urandom | fold -w${pass_lenght} | head -n 1); done
for i in {1..10}; do (tr -cd '[:alnum:]' < /dev/urandom | fold -w${pass_length} | head -n 1); done

# Print the strings
printf "$pass_output\n"
Expand All @@ -102,13 +102,13 @@ printf "Goodbye, ${USER}\n"
# Ask user for the string length
clear
printf "\n"
read -p "How many characters you would like the password to have? " pass_lenght
read -p "How many characters you would like the password to have? " pass_length
printf "\n"

# This is where the magic happens!
# Generate a list of 10 strings and cut it to the desired value provided from the user

for i in {1..10}; do (tr -cd '[:alnum:]' < /dev/urandom | fold -w${pass_lenght} | head -n 1); done
for i in {1..10}; do (tr -cd '[:alnum:]' < /dev/urandom | fold -w${pass_length} | head -n 1); done

# Print the strings
printf "$pass_output\n"
Expand Down
12 changes: 6 additions & 6 deletions ebook/en/content/023-bash-redirection.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ In Linux, there are 3 File Descriptors, **STDIN** (0); **STDOUT** (1) and **STDE

# Difference between Pipes and Redirections

Both *pipes* and *redidertions* redirect streams `(file descriptor)` of process being executed. The main diffrence is that *redirections* deal with `files stream`, sending the output stream to a file or sending the content of a given file to the input stream of the process.
Both *pipes* and *redidertions* redirect streams `(file descriptor)` of process being executed. The main difference is that *redirections* deal with `files stream`, sending the output stream to a file or sending the content of a given file to the input stream of the process.

On the otherhand a pipe connects two commands by sending the output stream of the first one to the input stream of the second one. without any redidertions specified.
On the other hand a pipe connects two commands by sending the output stream of the first one to the input stream of the second one. without any redidertions specified.

# Redirection in Bash

Expand Down Expand Up @@ -58,7 +58,7 @@ Example:
echo "Hello World!" > file.txt
```
The following command will not print "Hello World" on the terminal screen, it will instead create a file called ``file.txt`` and will write the "Hello World" string to it.
This can be verified by runnning the ``cat`` command on the ``file.txt`` file.
This can be verified by running the ``cat`` command on the ``file.txt`` file.
```
cat file.txt
```
Expand Down Expand Up @@ -103,7 +103,7 @@ echo "Hello World!" 1> file.txt

## STDERR (Standard Error)

The error text on the terminal screen is printed via the **STDERR** of the the command. For example:
The error text on the terminal screen is printed via the **STDERR** of the command. For example:
```
ls --hello
```
Expand Down Expand Up @@ -160,7 +160,7 @@ Syntax:

You can also build arbitrary chains of commands by piping them together to achieve a powerful result.

This examble create a listing of every user which owns a file in a given directory as well as how many files and directories they own:
This example creates a listing of every user which owns a file in a given directory as well as how many files and directories they own:
```
ls -l /projects/bash_scripts | tail -n +2 | sed 's/\s\s*/ /g' | cut -d ' ' -f 3 | sort | uniq -c
```
Expand All @@ -182,7 +182,7 @@ COMMAND << EOF
...
EOF
```
Note here that `EOF` represents the delimiter (end of file) of the heredoc. In fact, we can use any alphanumeric word in it's place to signify the start and the end of the file. For instance, this is a valid heredoc:
Note here that `EOF` represents the delimiter (end of file) of the heredoc. In fact, we can use any alphanumeric word in its place to signify the start and the end of the file. For instance, this is a valid heredoc:
```
cat << randomword1
This script will print these lines on the terminal.
Expand Down
12 changes: 6 additions & 6 deletions ebook/en/content/024-automating-wordpress-lamp-with-bash.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Automatic Wordpress on LAMP installation with BASH
# Automatic WordPress on LAMP installation with BASH

Here is an example of a full LAMP and Wordpress installation that works on any Debian-based machine.
Here is an example of a full LAMP and WordPress installation that works on any Debian-based machine.

# Prerequisites

Expand Down Expand Up @@ -42,10 +42,10 @@ Let's start again by going over the main functionality of the script:
* Create a user
* Flush Privileges

**Wordpress Config**
**WordPress Config**

* Install required Wordpress PHP plugins
* Install Wordpress
* Install required WordPress PHP plugins
* Install WordPress
* Append the required information to `wp-config.php` file

Without further ado, let's start writing the script.
Expand Down Expand Up @@ -333,4 +333,4 @@ The script does the following:
* Install WordPress
* Configure WordPress

With this being said, I hope you enjoyed this example. If you have any questions, please feel free to ask me directly at [@denctl](https://twitter.com/denctl).
With this being said, I hope you enjoyed this example. If you have any questions, please feel free to ask me directly at [@denctl](https://twitter.com/denctl).
4 changes: 2 additions & 2 deletions ebook/en/content/100-bash-wrap-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ In this introduction to Bash scripting book, we just covered the basics, but you

As a next step try writing your own script and share it with the world! This is the best way to learn any new programming or scripting language!

In case that this book enspired you to write some cool Bash scripts, make sure to tweet about it and tag [@bobbyiliev_](https://twitter.com) so that we could check it out!
In case that this book inspired you to write some cool Bash scripts, make sure to tweet about it and tag [@bobbyiliev_](https://twitter.com) so that we could check it out!

Congrats again on completing this book!
Congrats again on completing this book!