Add lesson 2: Moving and copying files
3 changed files with 29 additions and 0 deletions
lessons/02-moving-and-copying-files/README.md ADDED
| @@ -0,0 +1,19 @@ | ||
| 1 | +# Lesson 2: Moving and copying files | |
| 2 | + | |
| 3 | +Moving and copying files comes up in almost every real shell project. We start with the why, then write code together. | |
| 4 | + | |
| 5 | +Full lesson: [https://glibcode.net/courses/linux-shell/lessons/2](https://glibcode.net/courses/linux-shell/lessons/2) | |
| 6 | + | |
| 7 | +## Files | |
| 8 | + | |
| 9 | +- `commands.sh`: copying, moving and removing safely | |
| 10 | + | |
| 11 | +## Run it | |
| 12 | + | |
| 13 | +```sh | |
| 14 | +# type the commands from commands.sh one by one; don't run it as a script | |
| 15 | +``` | |
| 16 | + | |
| 17 | +## Exercises | |
| 18 | + | |
| 19 | +See [exercises.md](exercises.md). Ask in the forum once you've tried. | |
lessons/02-moving-and-copying-files/commands.sh ADDED
| @@ -0,0 +1,5 @@ | ||
| 1 | +mkdir -p ~/practice/photos | |
| 2 | +cp ~/Pictures/*.jpg ~/practice/photos/ | |
| 3 | +mv ~/practice/photos/IMG_0001.jpg ~/practice/photos/beach.jpg | |
| 4 | +cp -r ~/practice ~/practice-backup | |
| 5 | +rm -i ~/practice/photos/*.tmp # -i asks before deleting | |
lessons/02-moving-and-copying-files/exercises.md ADDED
| @@ -0,0 +1,5 @@ | ||
| 1 | +# Exercises: lesson 2 | |
| 2 | + | |
| 3 | +1. Add a check that prints a warning when a result looks wrong (negative, empty, too big). | |
| 4 | +2. Add a comment above each block explaining what it does, in your own words. | |
| 5 | +3. Explain the example to someone who hasn't taken the course. Which part was hardest to explain? | |