← All courses

Bash scripts: from a loop to a robust script

Learn to write scripts that don't break on spaces in file names, empty arguments or failures — and schedule them with cron.

30 tasks · 1 question
  1. A loop with a countereasy
  2. Required Argument Checkeasy
  3. Check whether a file existseasy
  4. Repeat an action N timeseasy
  5. Argument with a default valueeasy
  6. Split a path into name and directoryeasy
  7. Count Non-Empty Lineseasy
  8. Branching with && and ||medium
  9. Quotes and spacesmedium
  10. Output to both the screen and a logmedium
  11. stdin, stdout, stderr and pipesinterview questioneasy
  12. Process files with spaces in their namesmedium
  13. Sum of argumentsmedium
  14. Sum of numbers from a filemedium
  15. Find the maximum in a filemedium
  16. Command Router Scriptmedium
  17. Validate input against a patternmedium
  18. Array in bashmedium
  19. A function that prints its resultmedium
  20. A script with flags via getoptsmedium
  21. A script with trap cleanupmedium
  22. Backup Script with the Date in the Filenamemedium
  23. Limit execution timeeasy
  24. Wait for a background job and grab its exit codemedium
  25. Don't let the script run twicehard
  26. Retry with increasing delayshard
  27. An evening report on a scheduleeasy
  28. Fix PATH for a cron jobmedium
  29. Publishing doesn't notice the errormedium
  30. A size-counting script: zero warningsmedium
  31. A robust scripthard