├── 01-saying-hello ├── README.md └── index.bash ├── 02-counting-characters ├── README.md ├── challenge.bash └── index.bash ├── 03-printing-qoutes ├── README.md └── index.bash ├── 04-mad-lib ├── README.md └── index.bash ├── 05-simple-math ├── README.md └── index.bash ├── 06-retirement-calculator ├── README.md └── index.bash ├── 07-area-of-a-rectangular-room ├── README.md └── index.bash ├── 08-pizza-party ├── README.md └── index.bash ├── 09-paint-calculator ├── README.md └── index.bash ├── 10-self-checkout ├── README.md └── index.bash ├── 11-currency-conversion ├── README.md └── index.bash ├── 12-simple-interest ├── README.md └── index.bash ├── LICENSE.md ├── README.md ├── bash-logo-dark.jpg ├── bash-logo-light.png ├── git.bash └── init.bash /01-saying-hello/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Saying Hello

5 | 6 | The “Hello, World” program is the first program you learn 7 | to write in many languages, but it doesn’t involve any input. 8 | So create a program that prompts for your name and prints 9 | a greeting using your name. 10 | 11 | ## Example Output 12 | 13 | ``` 14 | What is your name? Brian 15 | Hello, Brian, nice to meet you! 16 | ``` 17 | 18 | ## Constraint 19 | 20 | - Keep the input, string concatenation, and output sepa- 21 | rate. 22 | 23 | 26 | -------------------------------------------------------------------------------- /01-saying-hello/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is your name? " ANSWER; 4 | 5 | echo "Hello, $ANSWER, nice to meet you!"; 6 | -------------------------------------------------------------------------------- /02-counting-characters/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Counting the Number of Characters

5 | 6 | Create a program that prompts for an input string and dis- 7 | plays output that shows the input string and the number of 8 | characters the string contains. 9 | 10 | ## Example Output 11 | 12 | ``` 13 | What is the input string? Homer 14 | Homer has 5 characters. 15 | ``` 16 | ## Constraints 17 | - Be sure the output contains the original string. 18 | - Use a single output statement to construct the output. 19 | - Use a built-in function of the programming language to 20 | determine the length of the string. 21 | 22 | ## Challenges 23 | 24 | -If the user enters nothing, state that the user must enter 25 | something into the program. -------------------------------------------------------------------------------- /02-counting-characters/challenge.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is the input string? " STR; 4 | 5 | if [ -z "$STR" ]; 6 | then 7 | echo "Hey! Try again and enter something."; 8 | else 9 | echo "$STR has ${#STR} characters."; 10 | fi 11 | -------------------------------------------------------------------------------- /02-counting-characters/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is the input string? " STR; 4 | 5 | STR_LENGTH=${#STR}; 6 | 7 | echo "$STR has $STR_LENGTH characters."; -------------------------------------------------------------------------------- /03-printing-qoutes/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Printing Qoutes

5 | 6 | Quotation marks are often used to denote the start and end 7 | of a string. But sometimes we need to print out the quotation 8 | marks themselves by using escape characters. 9 | 10 | Create a program that prompts for a quote and an author. 11 | Display the quotation and author as shown in the example 12 | output. 13 | 14 | ## Example Output 15 | 16 | ``` 17 | What is the quote? These aren't the droids you're looking for. 18 | Who said it? Obi-Wan Kenobi 19 | Obi-Wan Kenobi says, "These aren't the droids 20 | you're looking for." 21 | ``` 22 | 23 | ## Constraints 24 | 25 | - Use a single output statement to produce this output, 26 | using appropriate string-escaping techniques for quotes. 27 | 28 | - If your language supports string interpolation or string 29 | substitution, don’t use it for this exercise. Use string 30 | concatenation instead. 31 | -------------------------------------------------------------------------------- /03-printing-qoutes/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is the qoute? " QOUTE; 4 | 5 | read -p "Who said it? " AUTHOR; 6 | 7 | echo -e "$AUTHOR"" says, ""\"$QOUTE\""; 8 | -------------------------------------------------------------------------------- /04-mad-lib/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Mad Lib

5 | 6 | Mad libs are a simple game where you create a story tem- 7 | plate with blanks for words. You, or another player, then 8 | construct a list of words and place them into the story, cre- 9 | ating an often silly or funny story as a result. 10 | 11 | Create a simple mad-lib program that prompts for a noun, 12 | a verb, an adverb, and an adjective and injects those into a 13 | story that you create. 14 | 15 | ## Example Output 16 | 17 | ``` 18 | Enter your nickname: John 19 | Enter your age: 20 20 | Enter your gender: male 21 | 22 | Hey John! 23 | A 20 year old male guy like you sniffs code daily. 24 | That's hilarious! 25 | 26 | ``` 27 | 28 | ## Constraints 29 | 30 | - Use a single output statement for this program. 31 | - If your language supports string interpolation or string 32 | substitution, use it to build up the output. -------------------------------------------------------------------------------- /04-mad-lib/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "Enter your nickname: " NAME; 4 | 5 | read -p "Enter your age: " AGE; 6 | 7 | read -p "Enter your gender: " GENDER; 8 | 9 | echo -e "\nHey $NAME!\nA $AGE year old $GENDER guy like you sniffs code daily.\nThat's hilarious!\n"; 10 | -------------------------------------------------------------------------------- /05-simple-math/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Simple Math

5 | 6 | You’ll often write programs that deal with numbers. And 7 | depending on the programming language you use, you’ll 8 | have to convert the inputs you get to numerical data types. 9 | 10 | Write a program that prompts for two numbers. Print the 11 | sum, difference, product, and quotient of those numbers as 12 | shown in the example output: 13 | 14 | ## Example Output 15 | 16 | ```` 17 | What is the first number? 10 18 | What is the second number? 5 19 | 20 | 10 + 5 = 15 21 | 22 | 10 - 5 = 5 23 | 24 | 10 * 5 = 50 25 | 26 | 10 / 5 = 2 27 | 28 | ```` 29 | 30 | ## Constraints 31 | 32 | - Values coming from users will be strings. Ensure that 33 | you convert these values to numbers before doing the 34 | math. 35 | - Keep the inputs and outputs separate from the numerical 36 | conversions and other processing. 37 | - Generate a single output statement with line breaks in 38 | the appropriate spots. 39 | -------------------------------------------------------------------------------- /05-simple-math/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is the first number? " X; 4 | 5 | read -p "What is the second number? " Y; 6 | 7 | echo -e " 8 | $X + $Y = $(( X + Y )) \n 9 | $X - $Y = $(( X - Y )) \n 10 | $X * $Y = $(( X * Y )) \n 11 | $X / $Y = $(( X / Y )) \n 12 | "; 13 | -------------------------------------------------------------------------------- /06-retirement-calculator/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Retirement Calculator

5 | 6 | Your computer knows what the current year is, which means 7 | you can incorporate that into your programs. You just have 8 | to figure out how your programming language can provide 9 | you with that information. 10 | 11 | Create a program that determines how many years you have 12 | left until retirement and the year you can retire. It should 13 | prompt for your current age and the age you want to retire 14 | and display the output as shown in the example that follows. 15 | 16 | ## Example Output 17 | 18 | ```` 19 | What is your current age? 25 20 | At what age would you like to retire? 65 21 | You have 40 years left until you can retire. 22 | It's 2015, so you can retire in 2055. 23 | 24 | ```` 25 | 26 | ## Constraints 27 | 28 | - Again, be sure to convert the input to numerical data 29 | before doing any math. 30 | - Don’t hard-code the current year into your program. 31 | Get it from the system time via your programming lan- 32 | guage. 33 | -------------------------------------------------------------------------------- /06-retirement-calculator/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is your current age? " CURRENT_AGE; 4 | 5 | read -p "At what age would you like to retire? " OLD_AGE; 6 | 7 | DIFF=$(( OLD_AGE - CURRENT_AGE )); 8 | 9 | CURRENT_YEAR=$(date +%Y); 10 | 11 | RETIREMENT_YEAR=$(( CURRENT_YEAR + DIFF )); 12 | 13 | echo " 14 | You have $DIFF years left until you retire. 15 | It's $CURRENT_YEAR, so you can retire in $RETIREMENT_YEAR. 16 | "; -------------------------------------------------------------------------------- /07-area-of-a-rectangular-room/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Area of a Rectangular Room

5 | 6 | When working in a global environment, you’ll have to 7 | present information in both metric and Imperial units. And 8 | you’ll need to know when to do the conversion to ensure 9 | the most accurate results. 10 | 11 | Create a program that calculates the area of a room. Prompt 12 | the user for the length and width of the room in feet. Then 13 | display the area in both square feet and square meters. 14 | 15 | ## Example Output 16 | 17 | ```` 18 | What is the length of the room in feet? 15 19 | What is the width of the room in feet? 20 20 | 21 | You entered dimensions of 15 feet by 20 feet. 22 | The area is 23 | 300 square feet 24 | 24 square meters 25 | 26 | ```` 27 | 28 | >Basic formula for conversion: 1ft = 0.3m 29 | 30 | ## Constraints 31 | 32 | - Keep the calculations separate from the output. 33 | - Use a constant to hold the conversion factor. 34 | -------------------------------------------------------------------------------- /07-area-of-a-rectangular-room/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "What is the length of the room in feet? " LENGTH; 4 | 5 | read -p "What is the width of the room in feet? " WIDTH; 6 | 7 | AREA_IN_FEET=$(( LENGTH * WIDTH )); 8 | 9 | LENGTH_IN_M=$(( LENGTH * 3 / 10 )); 10 | 11 | WIDTH_IN_M=$(( WIDTH * 3 / 10 )); 12 | 13 | AREA_IN_SQUAREMETERS=$(( LENGTH_IN_M * WIDTH_IN_M )); 14 | 15 | echo " 16 | 17 | You entered dimensions of $LENGTH feet by $WIDTH feet. 18 | The area is 19 | $AREA_IN_FEET square feet 20 | $AREA_IN_SQUAREMETERS square meters 21 | 22 | "; 23 | -------------------------------------------------------------------------------- /08-pizza-party/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Pizza Party

5 | 6 | Division isn’t always exact, and sometimes you’ll write 7 | programs that will need to deal with the leftovers as a whole 8 | number instead of a decimal. 9 | 10 | Write a program to evenly divide pizzas. Prompt for the 11 | number of people, the number of pizzas, and the number of 12 | slices per pizza. Ensure that the number of pieces comes out 13 | even. Display the number of pieces of pizza each person 14 | should get. If there are leftovers, show the number of leftover 15 | pieces. 16 | 17 | ## Example Output 18 | 19 | ```` 20 | How many people? 8 21 | How many pizzas do you have? 2 22 | 23 | 24 | 8 people with 2 pizzas 25 | Each person gets 2 pieces of pizza. 26 | There are 0 leftover pieces. 27 | 28 | ```` -------------------------------------------------------------------------------- /08-pizza-party/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -e "\n [$] Pizza Party \n"; 4 | 5 | read -p "How many people? " PEOPLE; 6 | 7 | read -p "How many pizzas do you have? " PIZZAS; 8 | 9 | read -p "How many slices does each pizza have? " SLICES; 10 | 11 | echo " 12 | 13 | $PEOPLE people with $PIZZAS pizzas 14 | Each person get $(( PEOPLE / PIZZAS )) pieces of pizza. 15 | There are $(( PEOPLE % PIZZAS )) leftover pieces. 16 | 17 | "; 18 | 19 | -------------------------------------------------------------------------------- /09-paint-calculator/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Paint Calculator

5 | 6 | Sometimes you have to round up to the next number rather 7 | than follow standard rounding rules. 8 | 9 | Calculate gallons of paint needed to paint the ceiling of a 10 | room. Prompt for the length and width, and assume one 11 | gallon covers 350 square feet. Display the number of gallons 12 | needed to paint the ceiling as a whole number. 13 | 14 | ## Example Output 15 | 16 | ```` 17 | [$] Paint Calculator 18 | 19 | What is the length of the room? 36 20 | What is the width of the room? 10 21 | 22 | You will need to purchase 2 gallons 23 | of paint to cover 360 square feet. 24 | 25 | ```` 26 | 27 | ## Constraints 28 | 29 | - Use a constant to hold the conversion rate. 30 | - Ensure that you round up to the next whole number. -------------------------------------------------------------------------------- /09-paint-calculator/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -e "\n [$] Paint Calculator \n"; 4 | 5 | read -p "What is the length of the room? " LENGTH; 6 | 7 | read -p "What is the width of the room? " WIDTH; 8 | 9 | AREA=$(( LENGTH * WIDTH )); 10 | PAINT_IN_GALLONS=$(( AREA / 350 )); 11 | EXCESS_AREA=$(( AREA % 350 )); 12 | 13 | if [ "$EXCESS_AREA" -ge 0 ]; 14 | then 15 | (( ++PAINT_IN_GALLONS )); 16 | fi 17 | 18 | echo " 19 | You will need to purchase $PAINT_IN_GALLONS gallons 20 | of paint to cover $AREA square feet. 21 | "; -------------------------------------------------------------------------------- /10-self-checkout/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Self Checkout

5 | 6 | Working with multiple inputs and currency can introduce 7 | some tricky precision issues. 8 | 9 | Create a simple self-checkout system. Prompt for the prices 10 | and quantities of three items. Calculate the subtotal of the 11 | items. Then calculate the tax using a tax rate of 5.5%. Print 12 | out the line items with the quantity and total, and then print 13 | out the subtotal, tax amount, and total. 14 | 15 | ## Example Output 16 | 17 | ```` 18 | Enter the price of Item 1: 25 19 | Enter the quantity of Item 1: 2 20 | 21 | Enter the price of Item 2: 10 22 | Enter the quantity of Item 2: 1 23 | 24 | Enter the price of Item 3: 4 25 | Enter the quantity of Item 3: 1 26 | 27 | Subtotal: $ 64.00 28 | Tax: $ 3.52 29 | Total: $ 67.52 30 | 31 | ```` 32 | 33 | ## Constraints 34 | 35 | - Keep the input, processing, and output parts of your 36 | program separate. Collect the input, then do the math 37 | operations and string building, and then print out the 38 | output. 39 | 40 | - Be sure you explicitly convert input to numerical data 41 | before doing any calculations. 42 | 43 | ## Constraints 44 | 45 | - Use a single output statement. -------------------------------------------------------------------------------- /10-self-checkout/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | read -p "Enter the price of Item 1: " ITEM_1_PRICE; 4 | read -p "Enter the quantity of Item 1: " ITEM_1_QTY; 5 | 6 | echo ""; 7 | 8 | read -p "Enter the price of Item 2: " ITEM_2_PRICE; 9 | read -p "Enter the quantity of Item 2: " ITEM_2_QTY; 10 | 11 | echo ""; 12 | 13 | read -p "Enter the price of Item 3: " ITEM_3_PRICE; 14 | read -p "Enter the quantity of Item 3: " ITEM_3_QTY; 15 | 16 | echo ""; 17 | 18 | ITEM_1=$(( ITEM_1_PRICE * ITEM_1_QTY )); 19 | ITEM_2=$(( ITEM_2_PRICE * ITEM_2_QTY )); 20 | ITEM_3=$(( ITEM_3_PRICE * ITEM_3_QTY )); 21 | 22 | SUBTOTAL=$( echo "val = ($ITEM_1 + $ITEM_2 + $ITEM_3); scale=2; val / 1" | bc -l ); 23 | TAX=$( echo "val = ($SUBTOTAL / 1000) * 55; scale=2; val / 1" | bc -l ); 24 | TOTAL=$( echo "val = ($SUBTOTAL + $TAX); scale=2; val / 1" | bc -l ); 25 | 26 | echo -e "Subtotal: $ $SUBTOTAL"; 27 | echo -e "Tax: $ $TAX"; 28 | echo -e "Total: $ $TOTAL"; -------------------------------------------------------------------------------- /11-currency-conversion/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

11-currency-conversion

5 | 6 | At some point, you might have to deal with currency 7 | exchange rates, and you’ll need to ensure your calculations 8 | are as precise as possible. 9 | 10 | Write a program that converts currency. Specifically, convert 11 | euros to U.S. dollars. Prompt for the amount of money in 12 | euros you have, and prompt for the current exchange rate 13 | of the euro. Print out the new amount in U.S. dollars. 14 | 15 | ## Example 16 | 17 | ```` 18 | [$] Currency Converter 19 | 20 | [-] 1 EURO = 1.037 DOLLARS 21 | 22 | How many euros are you exchanging? 100 23 | 24 | 100 euros is equivalent to 103.73 dollars. 25 | 26 | ```` -------------------------------------------------------------------------------- /11-currency-conversion/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | printf "\n[$] Currency Converter \n"; 4 | 5 | # current exchange rate 6 | # 1 Euro = 1.0372701539 USD - default 7 | printf "\n[-] 1 EURO = 1.037 DOLLARS\n\n"; 8 | 9 | read -p "How many euros are you exchanging? " EUROS; 10 | 11 | DOLLARS=$( echo "val=($EUROS * 10373 / 10000); scale=2; val/1" | bc -l ); 12 | 13 | printf "\n$EUROS euros is equivalent to $DOLLARS dollars.\n\n"; 14 | -------------------------------------------------------------------------------- /12-simple-interest/README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

12-simple-interest

5 | 6 | Computing simple interest is a great way to quickly figure 7 | out whether an investment has value. It’s also a good way 8 | to get comfortable with explicitly coding the order of opera- 9 | tions in your programs. 10 | 11 | Create a program that computes simple interest. Prompt for 12 | the principal amount, the rate as a percentage, and the time, 13 | and display the amount accrued (principal + interest). 14 | The formula for simple interest is **A = P(1 + rt)**, where **P** is 15 | the _principal amount_, **r** is the _annual rate of interest_, **t** is the 16 | **number of years** the amount is invested, and **A** is the _amount 17 | at the end of the investment_. 18 | 19 | ## Example Output 20 | 21 | ```` 22 | 23 | Enter the principal: 1500 24 | Enter the rate of interest: 4.3 25 | Enter the number of years: 4 26 | After 4 years at 4.3%, the investment will be worth $1758. 27 | 28 | ```` 29 | 30 | ## Constraints 31 | 32 | - Prompt for the rate as a percentage (like 15 , not .15 ). 33 | Divide the input by 100 in your program. 34 | 35 | - Ensure that fractions of a cent are rounded up to the next penny. 36 | 37 | - Ensure that the output is formatted as money. 38 | -------------------------------------------------------------------------------- /12-simple-interest/index.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | printf "\n[$] Simple Interest Calculator \n\n"; 4 | 5 | # Simple Interest formula 6 | # A = P(1 + R*T) 7 | 8 | read -p "Enter the principal: " P; 9 | read -p "Enter the rate of the interest: " R; 10 | read -p "Enter the number of years: " T; 11 | 12 | A=$( echo "val=($P * (1 + ($R * $T / 100))); scale=2; val/1" | bc -l); 13 | 14 | printf "\nAfter $T years at $R , the investment will be worth \$$A\n\n"; 15 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Henry Hale (http://github.com/henryhale) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Bash Logo 3 |

4 |

Learn Bash Shell Scripting

5 | 6 | ## Introduction 7 | 8 | This repo is based on a book titled: **Exercises for Programmers: 57 challenges to Develop Your Coding Skills** by **_Brian P. Hogan_**, edited by _Susannah Davidson Pfalzer_. 9 | 10 | The book can be downloaded [here](https://github.com/Premalatha-success/Books-Python/blob/main/57%20Exercises%20for%20Programmers.pdf). 11 | 12 | > "_This book is all about practicing your craft as a programmer. 13 | >Flip to a page in this book, crack open your text editor, and 14 | >hammer out the program. Make your own variations on it. 15 | >Do it in a language you’ve never used before. And get better 16 | >and better each time you do it._" 17 | 18 | ## Contents 19 | 20 | Below is a list of programs built while learning Bash Shell Scripting 21 | 22 | 1. [Saying Hello](./01-saying-hello/) 23 | 2. [Counting Characters](./02-counting-characters/) 24 | 3. [Printing Qoutes](./03-printing-qoutes/) 25 | 4. [Mad Lib](./04-mad-lib/) 26 | 5. [Simple Math](./05-simple-math/) 27 | 6. [Retirement Calculator](./06-retirement-calculator/) 28 | 7. [Area of a Rectangular Room](./07-area-of-a-rectangular-room/) 29 | 8. [Pizza Party](./08-pizza-party/) 30 | 9. [Paint Calculator](./09-paint-calculator/) 31 | 10. [Self Checkout](./10-self-checkout/) 32 | 11. [Currency Conversion](./11-currency-conversion/) 33 | 12. [Simple Interest](./12-simple-interest/) 34 | 35 | ## Why? 36 | 37 | I qoute some of the most motivational statements I've ever read: 38 | 39 | > _"The best software developers I’ve ever met approach their 40 | >craft the same way. They don’t go to work every day and 41 | >practice on the employer’s dime. They invest personal time 42 | >in learning new languages and perfecting techniques in 43 | >others. Of course they learn new things on the job, but 44 | >because they’re getting paid, there’s an expectation that they 45 | >are there to perform, not practice."_ 46 | 47 | Most important of all... 48 | 49 | >_"But that’s the real value of these 50 | >exercises; they’ll help you learn a language and how that 51 | >language is different from what you already know."_ 52 | 53 | ## Development 54 | 55 | Clone this repository 56 | 57 | ```sh 58 | git clone https://github.com/henryhale/learn-bash.git 59 | ``` 60 | 61 | Navigate to the repository folder 62 | 63 | ```sh 64 | cd learn-bash 65 | ``` 66 | 67 | Make the `init.bash` file executable 68 | 69 | ```sh 70 | chmod +x init.bash 71 | ``` 72 | 73 | To get started with a new project, bootstrap one using: 74 | 75 | ```sh 76 | ./init.bash [project_name] 77 | ``` 78 | 79 | To save changes to remote repo, simply run and follow the prompts 80 | 81 | ```sh 82 | ./git.bash 83 | ``` 84 | 85 | ## More Resources 86 | 87 | ### Challenges 88 | 89 | - [CMD Challenge Website](https://cmdchallenge.com/) 90 | 91 | ### Archives 92 | - [PESU IO Shell Scripting - GitHub Archive](https://github.com/Gituser143/PESU-IO-Shell-Scripting) 93 | 94 | ### Videos 95 | 96 | - [Edureka's Shell Scripting Crash Course](https://www.youtube.com/watch?v=GtovwKDemnI) 97 | - [Brad Traversy's Shell Scripting Crash Course](https://www.youtube.com/watch?v=v-F3YLd6oMw) 98 | 99 | -------------------------------------------------------------------------------- /bash-logo-dark.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryhale/learn-bash/607f45e762ad6f301a7f4aaeaf365a3327465ade/bash-logo-dark.jpg -------------------------------------------------------------------------------- /bash-logo-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/henryhale/learn-bash/607f45e762ad6f301a7f4aaeaf365a3327465ade/bash-logo-light.png -------------------------------------------------------------------------------- /git.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -e "\n\t [-] Git Pusher\n\n\t - starting..."; 4 | 5 | echo -e "\n\t - adding..."; 6 | 7 | git add .; 8 | 9 | echo -e "\n\t - current status..."; 10 | 11 | git status; 12 | 13 | echo -e "\n\t - committing..."; 14 | 15 | echo -ne "\n\t > "; 16 | 17 | read -p "Enter commit message: " MSG; 18 | 19 | git commit -m "$MSG"; 20 | 21 | echo -e "\n\t - pushing changes..."; 22 | 23 | git push; 24 | 25 | echo -e "\n\t - ...done!\n"; 26 | -------------------------------------------------------------------------------- /init.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # init.sh - help create a full workspace of a new project 4 | # - containing all required files (C, Bash) 5 | 6 | echo -e "\n\t[-] Initializer"; 7 | 8 | echo -e "\n\t| - setup a new & ready-to-go workspace\n"; 9 | 10 | # promt user for project name 11 | read -p " | > Enter project name: " PROJECTDIR; 12 | 13 | # initialize a few variables 14 | D_SHELL="./$PROJECTDIR/index.bash"; 15 | 16 | # D_CFILE="./$PROJECTDIR/main.c"; 17 | D_README="./$PROJECTDIR/README.md"; 18 | 19 | # check whether the directory already exists otherwise create it 20 | if [ -d "./$PROJECTDIR" ]; 21 | then 22 | echo -e "\n\t| - ./$PROJECTDIR already exists "; 23 | echo -e "\n\t| - removing all files in ./$PROJECTDIR"; 24 | rm -rf "./$PROJECTDIR/*"; 25 | else 26 | echo -e "\n\t| - creating ./$PROJECTDIR"; 27 | mkdir "$PROJECTDIR"; 28 | fi 29 | 30 | echo -e "\n\t| - creating $D_SHELL"; 31 | 32 | # creating BASH shell file 33 | touch "$D_SHELL"; 34 | 35 | # make it executable 36 | chmod +x "$D_SHELL"; 37 | 38 | # add initial line 39 | echo "#!/usr/bin/env bash" > "$D_SHELL"; 40 | 41 | # creating readme.md file 42 | echo -e "\n\t| - creating $D_README"; 43 | touch "$D_README"; 44 | 45 | # add template 46 | echo -e "

47 | \"Bash 48 |

49 |

$PROJECTDIR

50 | 51 | ...about this repo 52 | " > "$D_README"; 53 | 54 | 55 | echo -e "\n\t| - finished...\n\n\t| Check if your project is setup,\n\n\ttype:\n\n\t| \$ cd $PROJECTDIR && ls\n"; 56 | 57 | --------------------------------------------------------------------------------