Skip to content

ndzuki/bash-scripts-zero-to-hero

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash Scripts, from zero to hero!

A collection of examples in Bash scripts.

See references of this repo here.

Introduction

  1. example1.sh: Declare variable and print it
  2. example2.sh: Remove variable
  3. example3.sh: Create readonly variable
  4. example4.sh: Raise error and break program
  5. example5.sh: Export vairable as environment vairable
  6. example6.sh: Special variables
  7. example7.sh: Special variables - get string and convert to array (by using $@)
  8. example8.sh: Special variables - check if program installed (by using $?)
  9. example9.sh: Arrays- Declare array and use it
  10. example10.sh: Arrays- create array from return of another command
  11. example11.sh: Run command inside file using backtick (`)
  12. example12.sh: Operators- arithmetic Operators (using expr and let)
  13. example13.sh: Get data from user (input)
  14. example14.sh: String conditions
  15. example15.sh: Integer conditions
  16. example16.sh: Operators- logical operators (-a, &&, -o, ||, !)
  17. example17.sh: File conditions
  18. example18.sh: Check SUID and GUID in files
  19. example19.sh: If statement
  20. example20.sh: Case Block
  21. example21.sh: Select Loop
  22. example22.sh: For Loop
  23. example23.sh: While Loop
  24. example24.sh: While Loop- more complex example
  25. example25.sh: Until Loop
  26. example26.sh: Until Loop- more complex example
  27. example27.sh: Loop- break command
  28. example28.sh: Loop- continue command
  29. example29.sh: Redirect- Introduction and simple commands
  30. example30.sh: Redirect- Appends to the file
  31. example31.sh: Redirect- Discard both stdout and stderr
  32. example32.sh: Redirect- Send the contents of a file to the stdin of a command
  33. example33.sh: Redirect- Complex redirection
  34. example34.sh: Redirect- Open custom file descriptor
  35. example35.sh: Redirect- Open a file for read and write with fd
  36. example36.sh: Redirect- List all file descriptors
  37. example37.sh: Redirect- tee and pip and pip&
  38. example38.sh: Get argument from terminal
  39. example39.sh: Function- Create functions and call it
  40. example40.sh: Function- Define and call function for calculate rectangle area
  41. example41.sh: Function- Get Return Value from Function
  42. example42.sh: Working with date
  43. example43.sh: Sleep Command

Mix Exercises

  1. mix_exercise1.sh: Install program after some check like directory exists, ownership and etc.
  2. mix_exercise2.sh: Create menu in terminal and choice opetions
  3. mix_exercise3.sh: Read a file line by line
  4. mix_exercise4.sh: Read the first three columns/fields from a file into variables
  5. mix_exercise5.sh: Read first line of file and put it into variable using redirection
  6. mix_exercise6.sh: Create directory if not exist
  7. mix_exercise7.sh: 4 arthimetrics operators
  8. mix_exercise8.sh: Factorial calculator
  9. mix_exercise9.sh: Lower case string
  10. mix_exercise10.sh: Upper case string

One Line Command

  1. one-line1.sh: Get size of file
  2. one-line2.sh: Extract file name from the path
  3. one-line3.sh: Generate the alphabet from a to z
  4. one-line4.sh: Genearte the alaphbet from a to z without space
  5. one-line5.sh: Pading numbers with leading zero
  6. one-line6.sh: Combine two set of strings
  7. one-line7.sh: Find and replace first occurrence with: ${var/find/replace}
  8. one-line8.sh: Find and replace all occurrence with: ${var//find/replace}
  9. one-line9.sh: Extract a substring from a string
  10. one-line10.sh: Change upper case to lower case and vice versa
  11. one-line11.sh: Get usage percent of specific file system

External Resources

  1. Bash Reference Manual: A brief description of the features that are present in the Bash shell (version 5.2, 19 September 2022)

About

A Collection for learning Bash step by step.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 99.6%
  • Python 0.4%