Hands-on task
A for loop: a copy of every log
The directory /root/logs holds logs — *.log files — and some other files next to them. Write the script /root/backup-logs.sh that uses a for loop to go through all the *.log files in that directory and, next to each one, makes a copy with a .bak suffix added: app.log → app.log.bak. Leave the other files alone.
There will be more logs over time, so don't write the file names into the script — let it find them on its own. When the script is ready, run it.
- bash scripts
- for loop
- filename patterns
- cp